From dc1ef34abacf790b0a4b6e49e465550775e12de7 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 31 Jan 2024 09:54:47 +0100 Subject: [PATCH 01/78] feat: refs #6493 refactorizar procedimientos vn2008 parte2 --- .../vn/procedures/available_traslate.sql | 123 +++++++++++ db/routines/vn/procedures/balance_create.sql | 204 ++++++++++++++++++ db/routines/vn/procedures/entry_recalc.sql | 2 +- .../procedures/article_multiple_buy.sql | 6 - .../procedures/article_multiple_buy_date.sql | 9 - db/routines/vn2008/procedures/buy_tarifas.sql | 6 - .../vn2008/procedures/buy_tarifas_entry.sql | 11 - db/routines/vn2008/procedures/traslado.sql | 4 +- .../10859-pinkGerbera/00-firstScript.sql | 15 ++ 9 files changed, 345 insertions(+), 35 deletions(-) create mode 100644 db/routines/vn/procedures/available_traslate.sql create mode 100644 db/routines/vn/procedures/balance_create.sql delete mode 100644 db/routines/vn2008/procedures/article_multiple_buy.sql delete mode 100644 db/routines/vn2008/procedures/article_multiple_buy_date.sql delete mode 100644 db/routines/vn2008/procedures/buy_tarifas.sql delete mode 100644 db/routines/vn2008/procedures/buy_tarifas_entry.sql create mode 100644 db/versions/10859-pinkGerbera/00-firstScript.sql diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql new file mode 100644 index 000000000..44b76d0c2 --- /dev/null +++ b/db/routines/vn/procedures/available_traslate.sql @@ -0,0 +1,123 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`available_traslate`( + vWarehouseLanding INT, + vDated DATE, + vWarehouseShipment INT) +proc: BEGIN + DECLARE vDatedFrom DATE; + DECLARE vDatedTo DATETIME; + DECLARE vDatedReserve DATETIME; + DECLARE vDatedInventory DATE; + + IF vDated < util.VN_CURDATE() THEN + LEAVE proc; + END IF; + + CALL item_getStock (vWarehouseLanding, vDated, NULL); + + + -- Calcula algunos parámetros necesarios + SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); + SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); + SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve + FROM hedera.orderConfig; + + -- Calcula el ultimo dia de vida para cada producto + CREATE OR REPLACE TEMPORARY TABLE tItemRange + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT c.itemFk, MAX(t.landed) dated + FROM buy c + JOIN entry e ON c.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom + AND t.warehouseInFk = vWarehouseLanding + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + GROUP BY c.itemFk; + + -- Tabla con el ultimo dia de last_buy para cada producto que hace un replace de la anterior + CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + + INSERT INTO tItemRange + SELECT t.itemFk, tr.landed + FROM tmp.buyUltimate t + JOIN buy b ON b.id = t.buyFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN tItemRange i ON t.itemFk = i.itemFk + WHERE t.warehouseFk = vWarehouseShipment + AND NOT e.isRaid + ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, tr.landed); + + CREATE OR REPLACE TEMPORARY TABLE tItemRangeLive + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT ir.itemFk, TIMESTAMP(TIMESTAMPADD(DAY, it.life, ir.dated), '23:59:59') dated + FROM tItemRange ir + JOIN item i ON i.id = ir.itemFk + JOIN itemType it ON it.id = i.typeFk + HAVING dated >= vDatedFrom OR dated IS NULL; + + -- Calcula el ATP + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc + (INDEX (itemFk,warehouseFk)) + ENGINE = MEMORY + SELECT i.item_id itemFk, vWarehouseLanding warehouseFk, i.dat dated, i.amount quantity + FROM vn2008.item_out i + JOIN tItemRangeLive ir ON ir.itemFK = i.item_id + WHERE i.dat >= vDatedFrom + AND (ir.dated IS NULL OR i.dat <= ir.dated) + AND i.warehouse_id = vWarehouseLanding + UNION ALL + SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity + FROM buy b + JOIN entry e ON b.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk + WHERE NOT e.isExcludedFromAvailable + AND b.quantity <> 0 + AND NOT e.isRaid + AND t.warehouseInFk = vWarehouseLanding + AND t.landed >= vDatedFrom + AND (ir.dated IS NULL OR t.landed <= ir.dated) + UNION ALL + SELECT i.item_id, vWarehouseLanding, i.dat, i.amount + FROM vn2008.item_entry_out i + JOIN tItemRangeLive ir ON ir.itemFk = i.item_id + WHERE i.dat >= vDatedFrom + AND (ir.dated IS NULL OR i.dat <= ir.dated) + AND i.warehouse_id = vWarehouseLanding + UNION ALL + SELECT r.item_id, vWarehouseLanding, r.shipment, -r.amount + FROM hedera.order_row r + JOIN hedera.`order` o ON o.id = r.order_id + JOIN tItemRangeLive ir ON ir.itemFk = r.item_id + WHERE r.shipment >= vDatedFrom + AND (ir.dated IS NULL OR r.shipment <= ir.dated) + AND r.warehouse_id = vWarehouseLanding + AND r.created >= vDatedReserve + AND NOT o.confirmed; + + CALL item_getAtp(vDated); + + CREATE OR REPLACE TEMPORARY TABLE availableTraslate + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT t.item_id, SUM(stock) available + FROM ( + SELECT ti.itemFk item_id, stock + FROM tmp.itemList ti + JOIN tItemRange ir ON ir.itemFk = ti.itemFk + UNION ALL + SELECT itemFk, quantity + FROM tmp.itemAtp + ) t + GROUP BY t.item_id + HAVING available <> 0; + + DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql new file mode 100644 index 000000000..9c22a4fd4 --- /dev/null +++ b/db/routines/vn/procedures/balance_create.sql @@ -0,0 +1,204 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`( + IN vStartingMonth INT, + IN vEndingMonth INT, + IN vCompany INT, + IN vIsConsolidated BOOLEAN, + IN vInterGroupSalesIncluded BOOLEAN) +BEGIN + DECLARE intGAP INT DEFAULT 7; + DECLARE vYears INT DEFAULT 2; + DECLARE vYear TEXT; + DECLARE vOneYearAgo TEXT; + DECLARE vTwoYearsAgo TEXT; + DECLARE vQuery TEXT; + DECLARE vConsolidatedGroup INT; + DECLARE vStartingDate DATE DEFAULT '2020-01-01'; + DECLARE vCurYear INT DEFAULT YEAR(util.VN_CURDATE()); + DECLARE vStartingYear INT DEFAULT vCurYear - 2; + DECLARE vTable TEXT; + + SET vTable = util.quoteIdentifier('balance_nest_tree'); + SET vYear = util.quoteIdentifier(vCurYear); + SET vOneYearAgo = util.quoteIdentifier(vCurYear-1); + SET vTwoYearsAgo = util.quoteIdentifier(vCurYear-2); + + -- Solicitamos la tabla tmp.nest, como base para el balance + DROP TEMPORARY TABLE IF EXISTS tmp.nest; + + EXECUTE IMMEDIATE CONCAT( + 'CREATE TEMPORARY TABLE tmp.nest + SELECT node.id + ,CONCAT( REPEAT(REPEAT(" ",?), COUNT(parent.id) - 1), node.name) AS name + ,node.lft + ,node.rgt + ,COUNT(parent.id) - 1 as depth + ,cast((node.rgt - node.lft - 1) / 2 as DECIMAL) as sons + FROM ', vTable, ' AS node, + ', vTable, ' AS parent + WHERE node.lft BETWEEN parent.lft AND parent.rgt + GROUP BY node.id + ORDER BY node.lft') + USING intGAP; + + CREATE OR REPLACE TEMPORARY TABLE tmp.balance + SELECT * FROM tmp.nest; + + DROP TEMPORARY TABLE IF EXISTS tmp.empresas_receptoras; + DROP TEMPORARY TABLE IF EXISTS tmp.empresas_emisoras; + + SELECT companyGroupFk INTO vConsolidatedGroup + FROM company + WHERE id = vCompany; + + CREATE OR REPLACE TEMPORARY TABLE tmp.empresas_receptoras + SELECT id empresa_id + FROM company + WHERE id = vCompany + OR companyGroupFk = IF(vIsConsolidated, vConsolidatedGroup, NULL); + + CREATE OR REPLACE TEMPORARY TABLE tmp.empresas_emisoras + SELECT id empresa_id FROM supplier p; + + IF vInterGroupSalesIncluded = FALSE THEN + + DELETE ee.* + FROM tmp.empresas_emisoras ee + JOIN company e on e.id = ee.empresa_id + WHERE e.companyGroupFk = vConsolidatedGroup; + + END IF; + + -- Se calculan las facturas que intervienen, para luego poder servir el desglose desde aqui + CREATE OR REPLACE TEMPORARY TABLE tmp.balance_desglose + SELECT er.empresa_id receptora_id, + ee.empresa_id emisora_id, + year(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`, + month(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`, + expenseFk Id_Gasto, + SUM(bi) importe + FROM invoiceIn r + JOIN invoiceInTax ri on ri.invoiceInFk = r.id + JOIN tmp.empresas_receptoras er on er.empresa_id = r.companyFk + JOIN tmp.empresas_emisoras ee ON ee.empresa_id = r.supplierFk + WHERE IFNULL(r.bookEntried,IFNULL(r.booked, r.issued)) >= vStartingDate + AND r.isBooked + GROUP BY Id_Gasto, year, month, emisora_id, receptora_id; + + INSERT INTO tmp.balance_desglose( + receptora_id, + emisora_id, + year, + month, + Id_Gasto, + importe) + SELECT gr.empresa_id, + gr.empresa_id, + year, + month, + Id_Gasto, + SUM(importe) + FROM vn2008.gastos_resumen gr + JOIN tmp.empresas_receptoras er on gr.empresa_id = er.empresa_id + WHERE year >= vStartingYear + AND month BETWEEN vStartingMonth AND vEndingMonth + GROUP BY Id_Gasto, year, month, gr.empresa_id; + + DELETE FROM tmp.balance_desglose + WHERE month < vStartingMonth + OR month > vEndingMonth; + + -- Ahora el balance + EXECUTE IMMEDIATE CONCAT( + 'ALTER TABLE tmp.balance + ADD COLUMN ', vTwoYearsAgo ,' INT(10) NULL , + ADD COLUMN ', vOneYearAgo ,' INT(10) NULL , + ADD COLUMN ', vYear,' INT(10) NULL , + ADD COLUMN Id_Gasto VARCHAR(10) NULL, + ADD COLUMN Gasto VARCHAR(45) NULL'); + + -- Añadimos los gastos, para facilitar el formulario + UPDATE tmp.balance b + JOIN vn2008.balance_nest_tree bnt on bnt.id = b.id + JOIN (SELECT id, name + FROM expense + GROUP BY id) g ON g.id = bnt.Id_Gasto COLLATE utf8_general_ci + SET b.Id_Gasto = g.id COLLATE utf8_general_ci + , b.Gasto = g.id COLLATE utf8_general_ci ; + + -- Rellenamos los valores de primer nivel, los que corresponden a los gastos simples + WHILE vYears >= 0 DO + SET vQuery = CONCAT( + 'UPDATE tmp.balance b + JOIN + (SELECT Id_Gasto, SUM(Importe) as Importe + FROM tmp.balance_desglose + WHERE year = ? + GROUP BY Id_Gasto + ) sub on sub.Id_Gasto = b.Id_Gasto COLLATE utf8_general_ci + SET ', util.quoteIdentifier(vCurYear - vYears), ' = - Importe'); + + EXECUTE IMMEDIATE vQuery + USING vCurYear - vYears; + + SET vYears = vYears - 1; + END WHILE; + + -- Añadimos las ventas + EXECUTE IMMEDIATE CONCAT( + 'UPDATE tmp.balance b + JOIN ( + SELECT SUM(IF(year = ?, venta, 0)) y2, + SUM(IF(year = ?, venta, 0)) y1, + SUM(IF(year = ?, venta, 0)) y0, + c.Gasto + FROM bs.ventas_contables c + JOIN tmp.empresas_receptoras er on er.empresa_id = c.empresa_id + WHERE month BETWEEN ? AND ? + GROUP BY c.Gasto + ) sub ON sub.Gasto = b.Id_Gasto COLLATE utf8_general_ci + SET b.', vTwoYearsAgo, '= IFNULL(b.', vTwoYearsAgo, ', 0) + sub.y2, + b.', vOneYearAgo, '= IFNULL(b.', vOneYearAgo, ', 0) + sub.y1, + b.', vYear, '= IFNULL(b.', vYear, ', 0) + sub.y0') + USING vCurYear-2, + vCurYear-1, + vCurYear, + vStartingMonth, + vEndingMonth; + + -- Ventas intra grupo + IF NOT vInterGroupSalesIncluded THEN + + SELECT lft, rgt INTO @grupoLft, @grupoRgt + FROM tmp.balance b + WHERE TRIM(b.`name`) = 'Grupo'; + + DELETE + FROM tmp.balance + WHERE lft BETWEEN @grupoLft AND @grupoRgt; + + END IF; + + -- Rellenamos el valor de los padres con la suma de los hijos + CREATE OR REPLACE TEMPORARY TABLE tmp.balance_aux + SELECT * FROM tmp.balance; + + EXECUTE IMMEDIATE + CONCAT('UPDATE tmp.balance b + JOIN ( + SELECT b1.id, + b1.name, + SUM(b2.', vYear,') thisYear, + SUM(b2.', vOneYearAgo,') oneYearAgo, + SUM(b2.', vTwoYearsAgo,') twoYearsAgo + FROM tmp.nest b1 + JOIN tmp.balance_aux b2 on b2.lft BETWEEN b1.lft and b1.rgt + GROUP BY b1.id)sub ON sub.id = b.id + SET b.', vYear, ' = thisYear, + b.', vOneYearAgo, ' = oneYearAgo, + b.', vTwoYearsAgo, ' = twoYearsAgo'); + + SELECT *, CONCAT('',ifnull(Id_Gasto,'')) newgasto + FROM tmp.balance; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/entry_recalc.sql b/db/routines/vn/procedures/entry_recalc.sql index 2410d380d..b426a9b5b 100644 --- a/db/routines/vn/procedures/entry_recalc.sql +++ b/db/routines/vn/procedures/entry_recalc.sql @@ -26,7 +26,7 @@ BEGIN LEAVE l; END IF; - CALL vn2008.buy_tarifas_entry(vEntryFk); + CALL buy_recalcPricesByEntry(vEntryFk); END LOOP; CLOSE vCur; diff --git a/db/routines/vn2008/procedures/article_multiple_buy.sql b/db/routines/vn2008/procedures/article_multiple_buy.sql deleted file mode 100644 index 5b0d402c5..000000000 --- a/db/routines/vn2008/procedures/article_multiple_buy.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`article_multiple_buy`(v_date DATETIME, wh INT) -BEGIN - CALL vn.item_multipleBuy(v_date, wh); -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/article_multiple_buy_date.sql b/db/routines/vn2008/procedures/article_multiple_buy_date.sql deleted file mode 100644 index 7b197cb01..000000000 --- a/db/routines/vn2008/procedures/article_multiple_buy_date.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`article_multiple_buy_date`( - IN vDated DATETIME, - IN vWarehouseFk TINYINT(3) -) -BEGIN - CALL vn.item_multipleBuyByDate(vDated, vWarehouseFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/buy_tarifas.sql b/db/routines/vn2008/procedures/buy_tarifas.sql deleted file mode 100644 index c6e8dff90..000000000 --- a/db/routines/vn2008/procedures/buy_tarifas.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_tarifas`(vBuyFk INT) -BEGIN - CALL vn.buy_recalcPricesByBuy(vBuyFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/buy_tarifas_entry.sql b/db/routines/vn2008/procedures/buy_tarifas_entry.sql deleted file mode 100644 index 3fc0739e0..000000000 --- a/db/routines/vn2008/procedures/buy_tarifas_entry.sql +++ /dev/null @@ -1,11 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_tarifas_entry`(IN vEntryFk INT(11)) -BEGIN -/** - * Recalcula los precios de una entrada - * - * @param vEntryFk - */ - CALL vn.buy_recalcPricesByEntry(vEntryFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/traslado.sql b/db/routines/vn2008/procedures/traslado.sql index 9c1e5efe7..0e302e156 100644 --- a/db/routines/vn2008/procedures/traslado.sql +++ b/db/routines/vn2008/procedures/traslado.sql @@ -61,7 +61,7 @@ BEGIN AND v.`visible` ON DUPLICATE KEY UPDATE visibleLanding = v.`visible`; - CALL availableTraslate(warehouseShipment, dateShipment, NULL); + CALL vn.available_traslate(warehouseShipment, dateShipment, NULL); INSERT INTO tmp.item(itemFk, available) SELECT a.item_id, a.available @@ -69,7 +69,7 @@ BEGIN WHERE a.available ON DUPLICATE KEY UPDATE available = a.available; - CALL availableTraslate(warehouseLanding, dateLanding, warehouseShipment); + CALL vn.available_traslate(warehouseLanding, dateLanding, warehouseShipment); INSERT INTO tmp.item(itemFk, availableLanding) SELECT a.item_id, a.available diff --git a/db/versions/10859-pinkGerbera/00-firstScript.sql b/db/versions/10859-pinkGerbera/00-firstScript.sql new file mode 100644 index 000000000..8fcadf605 --- /dev/null +++ b/db/versions/10859-pinkGerbera/00-firstScript.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE PROCEDURE `vn`.`balance_create`() BEGIN END; +CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByEntry`() BEGIN END; +CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByBuy`() BEGIN END; + +GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`; +GRANT EXECUTE ON PROCEDURE vn.balance_create TO `hrBoss`; + +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `claimManager`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `employee`; + +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `buyer`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `entryEditor`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `claimManager`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `employee`; \ No newline at end of file From 01512c7d36f2cdce1fa36010ecd79460316626d5 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 5 Feb 2024 13:52:28 +0100 Subject: [PATCH 02/78] feat: refs #6777 change dependecies vn2008 to vn --- .../bi/procedures/Greuge_Evolution_Add.sql | 10 ++-- .../bi/procedures/analisis_ventas_update.sql | 52 +++++++++---------- .../bi/procedures/claim_ratio_routine.sql | 24 ++++----- db/routines/bi/procedures/comparativa_add.sql | 10 ++-- .../bi/procedures/comparativa_add_manual.sql | 10 ++-- .../bs/procedures/comercialesCompleto.sql | 18 +++---- .../bs/procedures/manaCustomerUpdate.sql | 8 +-- .../bs/procedures/ventas_contables_add.sql | 20 +++---- .../ventas_contables_por_cliente.sql | 30 +++++------ .../vn/functions/getAlert3StateTest.sql | 14 ++--- .../vn/functions/isPalletHomogeneus.sql | 6 +-- .../vn/functions/ticketPositionInPath.sql | 6 +-- .../vn/procedures/invoiceFromAddress.sql | 11 ++-- .../vn2008/procedures/availableTraslate.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 12 ++--- .../procedures/confection_control_source.sql | 26 +++++----- .../vn2008/procedures/historico_multiple.sql | 2 +- db/routines/vn2008/views/Tickets_state.sql | 7 --- db/routines/vn2008/views/Tickets_turno.sql | 6 --- 19 files changed, 132 insertions(+), 142 deletions(-) delete mode 100644 db/routines/vn2008/views/Tickets_state.sql delete mode 100644 db/routines/vn2008/views/Tickets_turno.sql diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql index 83033cbf8..36491cbab 100644 --- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql +++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql @@ -92,12 +92,12 @@ BEGIN UPDATE bi.Greuge_Evolution ge JOIN ( SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + 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 - WHERE t.Fecha >= datFEC - AND t.Fecha < datFEC_TOMORROW + WHERE t.shipped >= datFEC + AND t.shipped < datFEC_TOMORROW AND mc.Id_Componente = 17 -- Recobro GROUP BY cs.Id_Cliente ) sub using(Id_Cliente) diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index 4f6a448ed..228660d07 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -10,18 +10,18 @@ BEGIN OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); INSERT INTO analisis_ventas ( - Familia, - Reino, - Comercial, - Comprador, - Provincia, - almacen, - Año, - Mes, - Semana, - Vista, - Importe - ) + Familia, + Reino, + Comercial, + Comprador, + Provincia, + almacen, + Año, + Mes, + Semana, + Vista, + Importe + ) SELECT tp.Tipo AS Familia, r.reino AS Reino, @@ -35,19 +35,19 @@ BEGIN dm.description AS Vista, bt.importe AS 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 vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista - LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn2008.province p ON p.province_id = cs.province_id - LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id - WHERE bt.fecha >= vLastMonth AND r.mercancia; + 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; END$$ DELIMITER ; diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 4616bcb9e..dce098e2d 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,18 +59,18 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.Id_Ticket + SELECT DISTINCT t.id FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Tickets_state ts ON ts.Id_Ticket = t.Id_Ticket - JOIN vn.ticketTracking tt ON tt.id = ts.inter_id - JOIN vn2008.state s ON s.id = tt.stateFk + JOIN vn.ticket t ON t.id = m.Id_Ticket + 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 - AND t.Fecha >= '2016-10-01' - AND t.Fecha < util.VN_CURDATE() - AND s.alert_level >= 3; + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND s.alertLevel >= 3; DELETE g.* FROM vn2008.Greuges g @@ -82,15 +82,15 @@ BEGIN SELECT Id_Cliente ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif - ,date(t.Fecha) + ,date(t.shipped) , 2 ,tt.Id_Ticket FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket + 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 - GROUP BY t.Id_Ticket + GROUP BY t.id HAVING ABS(dif) > 1; UPDATE vn2008.Movimientos_componentes mc diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql index 4297c8aff..ac06798db 100644 --- a/db/routines/bi/procedures/comparativa_add.sql +++ b/db/routines/bi/procedures/comparativa_add.sql @@ -15,17 +15,17 @@ BEGIN 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.warehouse_id, sum(m.Cantidad), sum(v.importe) + 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 vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3 - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + 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$$ diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql index 281e15b23..2b05b1277 100644 --- a/db/routines/bi/procedures/comparativa_add_manual.sql +++ b/db/routines/bi/procedures/comparativa_add_manual.sql @@ -25,16 +25,16 @@ BEGIN 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.warehouse_id, sum(m.Cantidad), sum(v.importe) + 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 vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN periodStart AND periodEnd - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + 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/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 323d5cd00..8f519b6ca 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,23 +70,23 @@ BEGIN 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.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + (SELECT t.clientFk, 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.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) + 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.Fecha) LastTicket, c.Id_Cliente - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente + (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.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente + GROUP BY t.clientFk) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente LEFT JOIN ( SELECT SUM(importe) peso, c.Id_Cliente diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index 1e9cb8429..7a4ee6dba 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -68,13 +68,13 @@ BEGIN FROM ( SELECT cs.Id_Cliente, Cantidad * Valor as mana - FROM vn2008.Tickets t + FROM vn.ticket t JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + 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) - AND t.Fecha > vFromDated - AND date(t.Fecha) <= vToDated + AND t.shipped > vFromDated + AND date(t.shipped) <= vToDated UNION ALL SELECT r.Id_Cliente, - Entregado FROM vn2008.Recibos r diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index d8e963e3e..554972e4c 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -19,11 +19,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) + (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk WHERE year(f.Fecha) = vYear AND month(f.Fecha) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , 7000000000 + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,12 +54,12 @@ BEGIN ) * 1000000 + tp.reino_id * 10000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + 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_Ticket = t.Id_Ticket + 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.empresa_id + 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 @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 9f1399025..26da1b870 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,38 +10,38 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura - WHERE year(f.Fecha) = vYear - AND month(f.Fecha) = vMonth; - + (PRIMARY KEY (id)) + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk + WHERE year(f.shipped) = vYear + AND month(f.shipped) = vMonth; + SELECT vYear Año, vMonth Mes, - t.Id_Cliente, + t.clientFk, 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.empresa_id empresa + t.companyFk empresa FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna + 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_Ticket = t.Id_Ticket + 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.empresa_id + 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.Id_Cliente, grupo,t.empresa_id; + GROUP BY t.clientFk, grupo,t.companyFk; DROP TEMPORARY TABLE tmp.ticket_list; - + END$$ DELIMITER ; diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index 6a14d80d4..beba0948c 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -11,9 +11,9 @@ BEGIN SELECT a.Vista INTO vDeliveryType - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - WHERE Id_Ticket = vTicket; + FROM ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + WHERE id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS @@ -23,11 +23,11 @@ BEGIN SET vCode = 'ON_DELIVERY'; ELSE -- MERCADO, OTROS - SELECT t.warehouse_id <> w.warehouse_id INTO isWaitingForPickUp - FROM vn2008.Tickets t + SELECT t.warehouseFk <> w.warehouse_id INTO isWaitingForPickUp + FROM ticket t LEFT JOIN vn2008.warehouse_pickup w - ON w.agency_id = t.Id_Agencia AND w.warehouse_id = t.warehouse_id - WHERE t.Id_Ticket = vTicket; + ON w.agency_id = t.agencyModeFk AND w.warehouse_id = t.warehouseFk + WHERE t.id = vTicket; IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; diff --git a/db/routines/vn/functions/isPalletHomogeneus.sql b/db/routines/vn/functions/isPalletHomogeneus.sql index 39c6461ae..05c20a71b 100644 --- a/db/routines/vn/functions/isPalletHomogeneus.sql +++ b/db/routines/vn/functions/isPalletHomogeneus.sql @@ -14,12 +14,12 @@ BEGIN SELECT COUNT(*) INTO vDistinctRoutesInThePallet FROM ( - SELECT DISTINCT t.Id_Ruta + SELECT DISTINCT t.routeFk FROM vn2008.scan_line sl JOIN vn2008.expeditions e ON e.expeditions_id = sl.code - JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticket_id + JOIN ticket t ON t.id = e.ticket_id WHERE sl.scan_id = vScanId - AND t.Id_Ruta + AND t.routeFk ) t1; RETURN vDistinctRoutesInThePallet = 1; diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 9bd2c110e..9a3bb4a0e 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -28,10 +28,10 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) SELECT (ag.`name` = 'VN_VALENCIA') INTO vIsValenciaPath - FROM vn2008.Rutas r - JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia + FROM `route` r + JOIN vn2008.Agencias a on a.Id_Agencia = r.agencyModeFk JOIN vn2008.agency ag on ag.agency_id = a.agency_id - WHERE r.Id_Ruta = vMyPath; + WHERE r.id = vMyPath; IF vIsValenciaPath THEN -- Rutas Valencia diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bde7afd8c..bea49e747 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -10,10 +10,13 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets WHERE (Fecha BETWEEN vMinDateTicket - AND vMaxTicketDate) AND Id_Consigna = vAddress - AND Factura IS NULL AND empresa_id = vCompany; + ENGINE = MEMORY + SELECT id id + FROM ticket + WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) + AND addressFk = vAddress + AND refFk IS NULL + AND companyFk = vCompany; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql index 6328560c8..399302d7b 100644 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ b/db/routines/vn2008/procedures/availableTraslate.sql @@ -18,7 +18,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT inventoried INTO vDatedInventory FROM vn.config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index bd8a324c6..dba4799d9 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -34,8 +34,8 @@ proc: BEGIN WHERE t.Fecha < vDate; DELETE tobs - FROM ticket_observation tobs - JOIN Tickets t ON tobs.Id_Ticket = t.Id_Ticket + FROM ticketObservation tobs + JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket WHERE t.Fecha < vDate; DELETE tobs @@ -45,10 +45,10 @@ proc: BEGIN DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; - DELETE tt.* - FROM Tickets_turno tt - LEFT JOIN Movimientos m USING(Id_Ticket) - WHERE m.Id_Article IS NULL; + DELETE tw.* + FROM vn.ticketWeekly tw + LEFT JOIN vn.sale s USING(ticketFk) + WHERE s.Id_Article IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 77b4df5f3..2951e9c38 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -11,33 +11,33 @@ BEGIN CREATE TEMPORARY TABLE tmp.production_buffer ENGINE = MEMORY SELECT - date(t.Fecha) as Fecha, - hour(t.Fecha) as Hora, - hour(t.Fecha) as Departure, - t.Id_Ticket, + date(t.shipped) as Fecha, + hour(t.shipped) as Hora, + hour(t.shipped) as Departure, + t.id, m.Id_Movimiento, m.Cantidad, m.Concepte, ABS(m.Reservado) Reservado, i.Categoria, tp.Tipo, - t.Alias as Cliente, + t.nickname as Cliente, wh.name as Almacen, - t.warehouse_id, + t.warehouseFk, cs.province_id, a.agency_id, ct.description as Taller, stock.visible, stock.available - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - JOIN vn.warehouse wh ON wh.id = t.warehouse_id - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + JOIN vn.warehouse wh ON wh.id = t.warehouseFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id JOIN vn.confectionType ct ON ct.id = tp.confeccion - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN ( SELECT item_id, sum(visible) visible, sum(available) available @@ -61,7 +61,7 @@ BEGIN WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam - AND t.Fecha BETWEEN vDated AND vEndingDate + AND t.shipped BETWEEN vDated AND vEndingDate AND m.Cantidad > 0; -- Entradas diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index ae4045a34..c68fbf2ad 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -4,7 +4,7 @@ BEGIN DECLARE vDateInventory DATETIME; - SELECT Fechainventario INTO vDateInventory FROM tblContadores; + SELECT inventoried INTO vDateInventory FROM vn.config; SET @a = 0; diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql deleted file mode 100644 index be59a750f..000000000 --- a/db/routines/vn2008/views/Tickets_state.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_state` -AS SELECT `t`.`ticketFk` AS `Id_Ticket`, - `t`.`ticketTrackingFk` AS `inter_id`, - `t`.`name` AS `state_name` -FROM `vn`.`ticketLastState` `t` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql deleted file mode 100644 index 28bc2d55f..000000000 --- a/db/routines/vn2008/views/Tickets_turno.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_turno` -AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, - `tw`.`weekDay` AS `weekDay` -FROM `vn`.`ticketWeekly` `tw` From 350088614991bee0909b1ba54af10b14ff72ff6d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 08:37:28 +0100 Subject: [PATCH 03/78] feat: refs #6777 tabulacion --- .../procedures/confection_control_source.sql | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 2951e9c38..6833cd29d 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -15,31 +15,31 @@ BEGIN hour(t.shipped) as Hora, hour(t.shipped) as Departure, t.id, - m.Id_Movimiento, + m.Id_Movimiento, m.Cantidad, m.Concepte, - ABS(m.Reservado) Reservado, + ABS(m.Reservado) Reservado, i.Categoria, - tp.Tipo, + tp.Tipo, t.nickname as Cliente, wh.name as Almacen, t.warehouseFk, cs.province_id, a.agency_id, - ct.description as Taller, - stock.visible, - stock.available + ct.description as Taller, + stock.visible, + stock.available FROM vn.ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk JOIN vn.warehouse wh ON wh.id = t.warehouseFk JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id - JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article + JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id - JOIN vn.confectionType ct ON ct.id = tp.confeccion + JOIN vn.confectionType ct ON ct.id = tp.confeccion JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - LEFT JOIN - ( + LEFT JOIN + ( SELECT item_id, sum(visible) visible, sum(available) available FROM ( @@ -57,12 +57,12 @@ BEGIN where cc.cache_id IN (2,8) and cc.params IN ("1","44") ) sub GROUP BY item_id - ) stock ON stock.item_id = m.Id_Article + ) stock ON stock.item_id = m.Id_Article WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam AND t.shipped BETWEEN vDated AND vEndingDate - AND m.Cantidad > 0; + AND m.Cantidad > 0; -- Entradas @@ -74,9 +74,9 @@ BEGIN Categoria, Cliente, Almacen, - Taller + Taller ) - SELECT + SELECT tr.shipment AS Fecha, e.Id_Entrada AS Id_Ticket, c.Cantidad, @@ -96,10 +96,7 @@ BEGIN WHERE who.hasConfectionTeam AND tp.confeccion AND tr.shipment BETWEEN vDated AND vEndingDate; - - - SELECT * FROM tmp.production_buffer; - + SELECT * FROM tmp.production_buffer; END$$ DELIMITER ; From c598e62d1ecc50e77ef0662840ca1afff3d5acdc Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:03:33 +0100 Subject: [PATCH 04/78] feat: refs #6777 change dependencies vn2008 to vn part7 --- db/routines/bi/views/v_ventas_contables.sql | 10 +- db/routines/vn/views/ticketMRW.sql | 16 +-- .../procedures/ListaTicketsEncajados.sql | 36 ++--- db/routines/vn2008/procedures/clean.sql | 19 +-- .../procedures/customerDebtEvolution.sql | 32 ++--- .../emailYesterdayPurchasesByConsigna.sql | 16 +-- .../vn2008/procedures/embalajes_stocks.sql | 74 +++++----- .../procedures/embalajes_stocks_detalle.sql | 135 +++++++++--------- .../vn2008/procedures/historico_absoluto.sql | 20 +-- .../vn2008/procedures/historico_multiple.sql | 12 +- .../vn2008/procedures/preOrdenarRuta.sql | 24 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 12 +- .../vn2008/procedures/risk_vs_client_list.sql | 10 +- db/routines/vn2008/views/item_out.sql | 8 +- 14 files changed, 213 insertions(+), 211 deletions(-) diff --git a/db/routines/bi/views/v_ventas_contables.sql b/db/routines/bi/views/v_ventas_contables.sql index 373fcdd3f..82bbeeaac 100644 --- a/db/routines/bi/views/v_ventas_contables.sql +++ b/db/routines/bi/views/v_ventas_contables.sql @@ -11,13 +11,13 @@ AS SELECT `time`.`year` AS `year`, FROM ( ( ( - `vn2008`.`Tickets` `t` - JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`) + `vn`.`ticket` `t` + JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`) ) - JOIN `vn2008`.`Movimientos` `m` ON(`t`.`Id_Ticket` = `m`.`Id_Ticket`) + JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`) ) - JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`Fecha` AS date)) + JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date)) ) -WHERE `t`.`Fecha` >= '2014-01-01' +WHERE `t`.`shipped` >= '2014-01-01' GROUP BY `time`.`year`, `time`.`month` diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index d612c8742..2677b41e7 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -1,8 +1,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketMRW` -AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, - `Tickets`.`empresa_id` AS `empresa_id`, +AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`, + `ticket`.`companyFk` AS `empresa_id`, `Consignatarios`.`consignatario` AS `Consignatario`, `Consignatarios`.`domicilio` AS `DOMICILIO`, `Consignatarios`.`poblacion` AS `POBLACION`, @@ -19,13 +19,13 @@ AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, 0 ) AS `movil`, `Clientes`.`if` AS `IF`, - `Tickets`.`Id_Ticket` AS `Id_Ticket`, - `Tickets`.`warehouse_id` AS `warehouse_id`, + `ticket`.`id` AS `Id_Ticket`, + `ticket`.`warehouseFk` AS `warehouse_id`, `Consignatarios`.`id_consigna` AS `Id_Consigna`, `Paises`.`Codigo` AS `CodigoPais`, - `Tickets`.`Fecha` AS `Fecha`, + `ticket`.`shipped` AS `Fecha`, `province`.`province_id` AS `province_id`, - `Tickets`.`landing` AS `landing` + `ticket`.`landed` AS `landing` FROM ( ( ( @@ -35,8 +35,8 @@ FROM ( `Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente` ) ) - JOIN `vn2008`.`Tickets` ON( - `Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna` + JOIN `vn`.`ticket` ON( + `Consignatarios`.`id_consigna` = `ticket`.`addressFk` ) ) JOIN `vn2008`.`province` ON( diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index 3d3318c63..e220cd9ad 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -2,24 +2,24 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int) BEGIN -SELECT Agencia, - Consignatario, - ti.Id_Ticket, - ts.userFk Id_Trabajador, - IFNULL(ncajas,0) AS ncajas, - IFNULL(nbultos,0) AS nbultos, - IFNULL(notros,0) AS notros, - ts.code AS Estado - FROM Tickets ti - INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna - INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia - LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.Id_Ticket=sub1.Ticket_Id - LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.Id_Ticket=sub2.Ticket_Id - LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.Id_Ticket=sub3.Ticket_Id - INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk - WHERE ti.Fecha=util.VN_CURDATE() AND - ts.userFk=intId_Trabajador - GROUP BY ti.Id_Ticket; + SELECT Agencia, + Consignatario, + ti.id Id_Ticket, + ts.userFk Id_Trabajador, + IFNULL(ncajas,0) AS ncajas, + IFNULL(nbultos,0) AS nbultos, + IFNULL(notros,0) AS notros, + ts.code AS Estado + FROM Tickets ti + INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna + INNER JOIN Agencias ON ti.agencyModeFk = Agencias.Id_Agencia + LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.id=sub1.Ticket_Id + LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.id=sub2.Ticket_Id + LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.id=sub3.Ticket_Id + INNER JOIN vn.ticketState ts ON ti.id = ts.ticketFk + WHERE ti.shipped=util.VN_CURDATE() AND + ts.userFk=intId_Trabajador + GROUP BY ti.id; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index dba4799d9..00279c090 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -30,18 +30,19 @@ proc: BEGIN DELETE ts FROM Tickets_stack ts - JOIN Tickets t ON ts.Id_Ticket = t.Id_Ticket - WHERE t.Fecha < vDate; + JOIN vn.ticket t ON ts.Id_Ticket = t.id + WHERE t.shipped < vDate; DELETE tobs FROM ticketObservation tobs - JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket - WHERE t.Fecha < vDate; + JOIN vn.ticket t ON tobs.ticketFk = t.id + WHERE t.shipped < vDate; DELETE tobs FROM movement_label tobs JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento - JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate; + JOIN vn.ticket t ON m.Id_Ticket = t.id + WHERE t.shipped < vDate; DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; @@ -92,9 +93,9 @@ proc: BEGIN END IF; -- Tickets Nulos PAK 11/10/2016 - UPDATE Tickets - SET empresa_id = 965 - WHERE Id_Cliente = 31 - AND empresa_id != 965; + UPDATE vn.ticket + SET companyFk = 965 + WHERE clientFk = 31 + AND companyFk != 965; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index e5d23f0ef..f6f81e2b0 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -13,28 +13,28 @@ SELECT * FROM LEFT JOIN (SELECT Euros, date(Fecha) as Fecha FROM ( - SELECT Fechacobro as Fecha, Entregado as Euros + SELECT Fechacobro as Fecha, Entregado as Euros FROM Recibos WHERE Id_Cliente = vCustomer - AND Fechacobro >= '2017-01-01' - UNION ALL - SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe + AND Fechacobro >= '2017-01-01' + UNION ALL + SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe FROM Facturas f - JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente + JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente WHERE f.Id_Cliente = vCustomer - AND Fecha >= '2017-01-01' - UNION ALL - SELECT '2016-12-31', Debt + AND Fecha >= '2017-01-01' + UNION ALL + SELECT '2016-12-31', Debt FROM bi.customerDebtInventory WHERE Id_Cliente = vCustomer - UNION ALL - SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100) - FROM Tickets t - JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket - WHERE Id_Cliente = vCustomer - AND Factura IS NULL - AND Fecha >= '2017-01-01' - GROUP BY Fecha + UNION ALL + SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) + FROM vn.ticket t + JOIN Movimientos m on m.Id_Ticket = t.id + WHERE t.clientFk = vCustomer + AND t.refFk IS NULL + AND t.shipped >= '2017-01-01' + GROUP BY t.shipped ) sub2 ORDER BY Fecha )sub ON time.date = sub.Fecha diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 439eba5ad..2a753157d 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,8 +14,8 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION - FROM Tickets t + SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + FROM vn.ticket t JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna JOIN ( SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, @@ -24,15 +24,15 @@ BEGIN ) AS `amount` FROM ( `vn2008`.`Movimientos` - JOIN `vn2008`.`Tickets` ON( - `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket` + JOIN `vn`.`ticket` ON( + `Movimientos`.`Id_Ticket` = `ticket`.`id` ) ) - WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH + WHERE `ticket`.`shipped` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH GROUP BY `Movimientos`.`Id_Ticket` - ) v ON v.Id_Ticket = t.Id_Ticket - WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date) - AND t.Id_Cliente = v_Client_Id; + ) v ON v.Id_Ticket = t.id + WHERE t.shipped BETWEEN v_Date AND util.dayEnd(v_Date) + AND t.clientFk = v_Client_Id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index b20e44c79..f6b0d9b9a 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -2,50 +2,50 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN) BEGIN -if bolCLIENT then + IF bolCLIENT THEN - select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo - from Movimientos m - join Articles a on m.Id_Article = a.Id_Article - join Tipos tp on tp.tipo_id = a.tipo_id - join Tickets t using(Id_Ticket) - join Consignatarios cs using(Id_Consigna) - where cs.Id_Cliente = idPEOPLE - and Tipo = 'Contenedores' - and t.Fecha > '2010-01-01' - group by m.Id_Article; + SELECT m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) Saldo + FROM Movimientos m + JOIN Articles a ON m.Id_Article = a.Id_Article + JOIN Tipos tp ON tp.tipo_id = a.tipo_id + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + WHERE cs.Id_Cliente = idPEOPLE + AND Tipo = 'Contenedores' + AND t.shipped > '2010-01-01' + GROUP BY m.Id_Article; -else + ELSE -select Id_Article, Article, sum(Cantidad) as Saldo -from -(select Id_Article, Cantidad -from Compres c -join Articles a using(Id_Article) -join Tipos tp using(tipo_id) -join Entradas e using(Id_Entrada) -join travel tr on tr.id = travel_id -where Id_Proveedor = idPEOPLE -and landing >= '2010-01-01' -and reino_id = 6 + SELECT Id_Article, Article, sum(Cantidad) Saldo + FROM + (SELECT Id_Article, Cantidad + FROM Compres c + JOIN Articles a using(Id_Article) + JOIN Tipos tp using(tipo_id) + JOIN Entradas e using(Id_Entrada) + JOIN travel tr ON tr.id = travel_id + WHERE Id_Proveedor = idPEOPLE + AND landing >= '2010-01-01' + AND reino_id = 6 -union all + union all -select Id_Article, - Cantidad -from Movimientos m -join Articles a using(Id_Article) -join Tipos tp using(tipo_id) -join Tickets t using(Id_Ticket) -join Consignatarios cs using(Id_Consigna) -join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente -where Id_Proveedor = idPEOPLE -and reino_id = 6 -and t.Fecha > '2010-01-01') mov + SELECT Id_Article, - Cantidad + FROM Movimientos m + JOIN Articles a using(Id_Article) + JOIN Tipos tp using(tipo_id) + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente + WHERE Id_Proveedor = idPEOPLE + AND reino_id = 6 + AND t.shipped > '2010-01-01') mov -join Articles a using(Id_Article) -group by Id_Article; + JOIN Articles a using(Id_Article) + GROUP BY Id_Article; -end if; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index c49d1b88a..0319e0f75 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -2,77 +2,78 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN) BEGIN + IF bolCLIENT THEN -if bolCLIENT then + SELECT m.Id_Article + , Article + , IF(Cantidad < 0, - Cantidad, NULL) Entrada + , IF(Cantidad < 0, NULL, Cantidad) Salida + , 'T' Tabla + , t.id Registro + , t.shipped Fecha + , w.name Almacen + , cast(Preu as Decimal(5,2)) Precio + , c.Cliente Proveedor + , abbreviation Empresa + FROM Movimientos m + JOIN Articles a using(Id_Article) + JOIN ticket t ON t.id = m.Id_Ticket + JOIN empresa e ON e.id = t.companyFk + JOIN warehouse w ON w.id = t.warehouseFk + JOIN Consignatarios cs using(Id_Consigna) + JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente + WHERE cs.Id_Cliente = idPEOPLE + AND m.Id_Article = idARTICLE + AND t.shipped > '2010-01-01'; - select m.Id_Article - , Article - , IF(Cantidad < 0, - Cantidad, NULL) as Entrada - , IF(Cantidad < 0, NULL, Cantidad) as Salida - , 'T' as Tabla - , t.Id_Ticket as Registro - , t.Fecha - , w.name as Almacen - , cast(Preu as Decimal(5,2)) Precio - , c.Cliente as Proveedor - , abbreviation as Empresa - from Movimientos m - join Articles a using(Id_Article) - join Tickets t using(Id_Ticket) - join empresa e on e.id = t.empresa_id - join warehouse w on w.id = t.warehouse_id - join Consignatarios cs using(Id_Consigna) - join Clientes c on c.Id_Cliente = cs.Id_Cliente - where cs.Id_Cliente = idPEOPLE - and m.Id_Article = idARTICLE - and t.Fecha > '2010-01-01'; + ELSE -else + SELECT Id_Article, + Tabla, + Registro, + Fecha, + Article, + w.name Almacen, + Entrada, + Salida, + Proveedor, + cast(Precio as Decimal(5,2)) Precio + FROM + (SELECT Id_Article + , IF(Cantidad > 0, Cantidad, NULL) Entrada + , IF(Cantidad > 0, NULL,- Cantidad) Salida + , 'E' Tabla + , Id_Entrada Registro + , landing Fecha + , tr.warehouse_id + , Costefijo Precio + FROM Compres c + JOIN Entradas e using(Id_Entrada) + JOIN travel tr ON tr.id = travel_id + WHERE Id_Proveedor = idPEOPLE + AND Id_Article = idARTICLE + AND landing >= '2010-01-01' -select Id_Article, Tabla, Registro, Fecha, Article -, w.name as Almacen, Entrada, Salida, Proveedor, cast(Precio as Decimal(5,2)) Precio - -from - -(select Id_Article - , IF(Cantidad > 0, Cantidad, NULL) as Entrada - , IF(Cantidad > 0, NULL,- Cantidad) as Salida - , 'E' as Tabla - , Id_Entrada as Registro - , landing as Fecha - , tr.warehouse_id - , Costefijo as Precio -from Compres c -join Entradas e using(Id_Entrada) -join travel tr on tr.id = travel_id -where Id_Proveedor = idPEOPLE -and Id_Article = idARTICLE -and landing >= '2010-01-01' - -union all - -select Id_Article - , IF(Cantidad < 0, - Cantidad, NULL) as Entrada - , IF(Cantidad < 0, NULL, Cantidad) as Salida - , 'T' - , Id_Ticket - , Fecha - , t.warehouse_id - , Preu -from Movimientos m -join Tickets t using(Id_Ticket) -join Consignatarios cs using(Id_Consigna) -join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente -where Id_Proveedor = idPEOPLE -and Id_Article = idARTICLE -and t.Fecha > '2010-01-01') mov - -join Articles a using(Id_Article) -join Proveedores p on Id_Proveedor = idPEOPLE -join warehouse w on w.id = mov.warehouse_id -; - -end if; + union all + SELECT Id_Article + , IF(Cantidad < 0, - Cantidad, NULL) Entrada + , IF(Cantidad < 0, NULL, Cantidad) Salida + , 'T' + , Id_Ticket + , Fecha + , t.warehouseFk warehouse_id + , Preu + FROM Movimientos m + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente + WHERE Id_Proveedor = idPEOPLE + AND Id_Article = idARTICLE + AND t.shipped > '2010-01-01') mov + JOIN Articles a using(Id_Article) + JOIN Proveedores p ON Id_Proveedor = idPEOPLE + JOIN warehouse w ON w.id = mov.warehouse_id; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 1a7e1dbfa..55f33ee89 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -50,20 +50,20 @@ BEGIN AND E.Inventario = 0 AND E.Redada = 0 UNION ALL - SELECT T.Fecha Fecha, + SELECT t.shipped Fecha, NULL Entrada, M.Cantidad Salida, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK, - T.Alias Alias, - T.Factura Referencia, - T.Id_Ticket, - T.PedidoImpreso + (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, + t.nickname Alias, + t.refFk Referencia, + t.id Id_Ticket, + t.isPrinted PedidoImpreso FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' + INNER JOIN ticket t USING (Id_Ticket) + JOIN Clientes C ON C.Id_Cliente = t.clientFk + WHERE t.shipped >= '2001-01-01' AND M.Id_Article = idART - AND wh IN (T.warehouse_id , 0) + AND wh IN (t.warehouseFk , 0) ) t1 ORDER BY Fecha, Entrada DESC, OK DESC; diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index c68fbf2ad..fbec7bb1d 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -66,17 +66,17 @@ BEGIN UNION ALL - SELECT T.Fecha as Fecha, + SELECT t.shipped as Fecha, NULL as Entrada, M.Cantidad as Salida, warehouse_id as wh, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, - T.Factura as Referencia, - T.Id_Ticket as id + (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK, + t.refFk as Referencia, + t.id as id FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - WHERE T.Fecha >= vDateInventory + INNER JOIN ticket t ON t.id = M.Id_Ticket + WHERE t.shipped >= vDateInventory AND M.Id_Article = vItemFk ) AS Historia diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index b5fd2b24b..9bcf853bd 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -6,17 +6,17 @@ BEGIN * DEPRECATED use vn.routeGressPriority */ -UPDATE Tickets mt -JOIN ( - SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad - from Tickets t - JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna - where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) - AND tt.Id_Ruta = vRutaId - GROUP BY Id_Consigna - ) sub ON sub.Id_Consigna = mt.Id_Consigna - SET mt.Prioridad = sub.Prioridad - WHERE mt.Id_Ruta = vRutaId; - + UPDATE vn.ticket mt + JOIN ( + SELECT tt.addressFk Id_Consigna, round(ifnull(avg(t.priority),0),0) as Prioridad + FROM vn.ticket t + JOIN vn.ticket tt on tt.addressFk = t.addressFk + WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) + AND tt.routeFk = vRutaId + GROUP BY addressFk + ) sub ON sub.Id_Consigna = mt.Id_Consigna + SET mt.priority = sub.Prioridad + WHERE mt.routeFk = vRutaId; + END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index e407a91b7..07cff3ff5 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -5,17 +5,17 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) ENGINE = MEMORY - SELECT t.Id_Ticket, c.Id_Cliente - FROM Tickets t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket - JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente + SELECT t.id Id_Ticket, c.Id_Cliente + FROM vn.ticket t + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN Clientes c ON c.Id_Cliente = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( Fecha BETWEEN util.today() AND vEndingDate OR ( ts.alertLevel < 3 - AND t.Fecha >= vStartingDate - AND t.Fecha < util.today() + AND t.shipped >= vStartingDate + AND t.shipped < util.today() ) ); END$$ diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index 92f94eb9f..bb3c1028c 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -33,14 +33,14 @@ BEGIN CREATE TEMPORARY TABLE tmp.tickets_sin_facturar (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY - SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total + SELECT t.clientFk Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total FROM Movimientos m - JOIN Tickets t on m.Id_Ticket = t.Id_Ticket - JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente - JOIN vn.client cl ON cl.id = t.Id_Cliente + JOIN vn.ticket t on m.Id_Ticket = t.id + JOIN tmp.client_list c on c.Id_Cliente = t.clientFk + JOIN vn.client cl ON cl.id = t.clientFk WHERE Factura IS NULL AND Fecha BETWEEN startingDate AND endingDate - GROUP BY t.Id_Cliente; + GROUP BY t.clientFk; DROP TEMPORARY TABLE IF EXISTS tmp.risk; CREATE TEMPORARY TABLE tmp.risk diff --git a/db/routines/vn2008/views/item_out.sql b/db/routines/vn2008/views/item_out.sql index 57353a6d6..a1e714cb6 100644 --- a/db/routines/vn2008/views/item_out.sql +++ b/db/routines/vn2008/views/item_out.sql @@ -1,17 +1,17 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`item_out` -AS SELECT `t`.`warehouse_id` AS `warehouse_id`, - `t`.`Fecha` AS `dat`, +AS SELECT `t`.`warehouseFk` AS `warehouse_id`, + `t`.`shipped` AS `dat`, `m`.`Id_Article` AS `item_id`, - `m`.`Cantidad` AS `amount`, `m`.`OK` AS `ok`, `m`.`Reservado` AS `Reservado`, - `t`.`Factura` AS `invoice`, + `t`.`refFk` AS `invoice`, `m`.`Id_Movimiento` AS `saleFk`, `m`.`Id_Ticket` AS `ticketFk` FROM ( `vn2008`.`Movimientos` `m` - JOIN `vn2008`.`Tickets` `t` ON(`m`.`Id_Ticket` = `t`.`Id_Ticket`) + JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`) ) WHERE `m`.`Cantidad` <> 0 From 714cd3c2c37f71bb4d83ccf07e83ac122f3f268c Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:55:20 +0100 Subject: [PATCH 05/78] feat: refs #6777 --- db/routines/bi/procedures/claim_ratio_routine.sql | 2 +- db/routines/bs/procedures/comercialesCompleto.sql | 2 +- db/routines/bs/procedures/ventas_contables_por_cliente.sql | 6 +++--- db/routines/vn/procedures/invoiceFromAddress.sql | 2 +- db/routines/vn2008/procedures/confection_control_source.sql | 2 +- db/routines/vn2008/procedures/customerDebtEvolution.sql | 2 +- .../vn2008/procedures/emailYesterdayPurchasesByConsigna.sql | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index dce098e2d..d7adbaba1 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,7 +59,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id + 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 diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 8f519b6ca..72b54656a 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,7 +70,7 @@ BEGIN 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, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + (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 diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26da1b870..31e93adb7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -14,12 +14,12 @@ BEGIN SELECT id FROM vn.ticket t JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk - WHERE year(f.shipped) = vYear - AND month(f.shipped) = vMonth; + WHERE year(f.Fecha) = vYear + AND month(f.Fecha) = vMonth; SELECT vYear Año, vMonth Mes, - t.clientFk, + t.clientFk Id_Cliente, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bea49e747..bf657a731 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -11,7 +11,7 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY - SELECT id id + SELECT id FROM ticket WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) AND addressFk = vAddress diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 6833cd29d..4b60b041e 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -23,7 +23,7 @@ BEGIN tp.Tipo, t.nickname as Cliente, wh.name as Almacen, - t.warehouseFk, + t.warehouseFk warehouse_id, cs.province_id, a.agency_id, ct.description as Taller, diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index f6f81e2b0..fad1a8a59 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -28,7 +28,7 @@ SELECT * FROM FROM bi.customerDebtInventory WHERE Id_Cliente = vCustomer UNION ALL - SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) + SELECT t.shipped Fecha, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) FROM vn.ticket t JOIN Movimientos m on m.Id_Ticket = t.id WHERE t.clientFk = vCustomer diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 2a753157d..7da510afa 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,7 +14,7 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION FROM vn.ticket t JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna JOIN ( From 747dabd1544a3f22492129591a63f4768682e2ed Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:41:22 +0100 Subject: [PATCH 06/78] feat: refs #6777 --- .../bi/procedures/claim_ratio_routine.sql | 2 +- .../bs/procedures/ventas_contables_add.sql | 2 +- .../vn/procedures/invoiceFromAddress.sql | 2 +- .../procedures/ListaTicketsEncajados.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 18 ++---------------- .../procedures/confection_control_source.sql | 2 +- .../emailYesterdayPurchasesByConsigna.sql | 4 ++-- .../vn2008/procedures/embalajes_stocks.sql | 8 ++++---- .../procedures/embalajes_stocks_detalle.sql | 10 +++++----- .../vn2008/procedures/historico_absoluto.sql | 2 +- .../vn2008/procedures/historico_multiple.sql | 6 +++--- .../vn2008/procedures/preOrdenarRuta.sql | 4 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 2 +- .../vn2008/procedures/risk_vs_client_list.sql | 4 ++-- 14 files changed, 27 insertions(+), 41 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index d7adbaba1..833a1153a 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -79,7 +79,7 @@ BEGIN INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha, Greuges_type_id, Id_Ticket) - SELECT Id_Cliente + SELECT t.clientFk ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif ,date(t.shipped) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 554972e4c..955356d4e 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -86,7 +86,7 @@ BEGIN ) as grupo , NULL , NULL - , t.companyFk + , t.companyFk empresa_id , 7050000000 FROM vn.ticketService ts JOIN vn.ticket t ON ts.ticketFk = t.id diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bf657a731..2879460ce 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -8,7 +8,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; - CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY SELECT id diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index e220cd9ad..6a9838da3 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -10,7 +10,7 @@ BEGIN IFNULL(nbultos,0) AS nbultos, IFNULL(notros,0) AS notros, ts.code AS Estado - FROM Tickets ti + FROM vn.ticket ti INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna INNER JOIN Agencias ON ti.agencyModeFk = Agencias.Id_Agencia LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.id=sub1.Ticket_Id diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index 00279c090..0ae70d648 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -22,19 +22,12 @@ proc: BEGIN DELETE FROM cdr WHERE calldate < vDate18; DELETE FROM Monitoring WHERE ODBC_TIME < vDate; - DELETE FROM Conteo WHERE Fecha < vDate; DELETE FROM mail WHERE DATE_ODBC < vDate; - DELETE FROM expeditions_deleted WHERE odbc_date < vDate26; DELETE FROM Movimientos_mark WHERE odbc_date < vDate; DELETE FROM Splits WHERE Fecha < vDate18; - DELETE ts - FROM Tickets_stack ts - JOIN vn.ticket t ON ts.Id_Ticket = t.id - WHERE t.shipped < vDate; - DELETE tobs - FROM ticketObservation tobs + FROM vn.ticketObservation tobs JOIN vn.ticket t ON tobs.ticketFk = t.id WHERE t.shipped < vDate; @@ -49,7 +42,7 @@ proc: BEGIN DELETE tw.* FROM vn.ticketWeekly tw LEFT JOIN vn.sale s USING(ticketFk) - WHERE s.Id_Article IS NULL; + WHERE s.id IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; @@ -65,13 +58,6 @@ proc: BEGIN JOIN travel t ON t.id = e.travel_id WHERE t.landing <= vDate; - DELETE co - FROM Compres_ok co JOIN Compres c ON c.Id_Compra = co.Id_Compra - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - JOIN travel t ON t.id = e.travel_id - WHERE t.landing <= vDate; - DELETE FROM scan WHERE odbc_date < vDate6 AND id <> 1; - IF v_full THEN CREATE OR REPLACE TEMPORARY TABLE tTicketDelete SELECT DISTINCT tl.originFk ticketFk diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 4b60b041e..84126bc8c 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -14,7 +14,7 @@ BEGIN date(t.shipped) as Fecha, hour(t.shipped) as Hora, hour(t.shipped) as Departure, - t.id, + t.id Id_Ticket, m.Id_Movimiento, m.Cantidad, m.Concepte, diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 7da510afa..be2f01d1f 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,9 +14,9 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, nickname Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION FROM vn.ticket t - JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna + JOIN Consignatarios cs ON t.addressFk = cs.Id_Consigna JOIN ( SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, sum( diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index f6b0d9b9a..6479b19f8 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -8,8 +8,8 @@ BEGIN FROM Movimientos m JOIN Articles a ON m.Id_Article = a.Id_Article JOIN Tipos tp ON tp.tipo_id = a.tipo_id - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk WHERE cs.Id_Cliente = idPEOPLE AND Tipo = 'Contenedores' AND t.shipped > '2010-01-01' @@ -35,8 +35,8 @@ BEGIN FROM Movimientos m JOIN Articles a using(Id_Article) JOIN Tipos tp using(tipo_id) - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND reino_id = 6 diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index 0319e0f75..2992e6029 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -17,10 +17,10 @@ BEGIN , abbreviation Empresa FROM Movimientos m JOIN Articles a using(Id_Article) - JOIN ticket t ON t.id = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket JOIN empresa e ON e.id = t.companyFk - JOIN warehouse w ON w.id = t.warehouseFk - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente WHERE cs.Id_Cliente = idPEOPLE AND m.Id_Article = idARTICLE @@ -65,8 +65,8 @@ BEGIN , t.warehouseFk warehouse_id , Preu FROM Movimientos m - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND Id_Article = idARTICLE diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 55f33ee89..e11fb64d5 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -59,7 +59,7 @@ BEGIN t.id Id_Ticket, t.isPrinted PedidoImpreso FROM Movimientos M - INNER JOIN ticket t USING (Id_Ticket) + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket JOIN Clientes C ON C.Id_Cliente = t.clientFk WHERE t.shipped >= '2001-01-01' AND M.Id_Article = idART diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index fbec7bb1d..b3ddc208a 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -69,19 +69,19 @@ BEGIN SELECT t.shipped as Fecha, NULL as Entrada, M.Cantidad as Salida, - warehouse_id as wh, + t.warehouseFk as wh, (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK, t.refFk as Referencia, t.id as id FROM Movimientos M - INNER JOIN ticket t ON t.id = M.Id_Ticket + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket WHERE t.shipped >= vDateInventory AND M.Id_Article = vItemFk ) AS Historia - INNER JOIN warehouse ON warehouse.id = Historia.wh + INNER JOIN vn.warehouse ON warehouse.id = Historia.wh ORDER BY Fecha, Entrada DESC, OK DESC; diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index 9bcf853bd..d3e1862f6 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -13,8 +13,8 @@ BEGIN JOIN vn.ticket tt on tt.addressFk = t.addressFk WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND tt.routeFk = vRutaId - GROUP BY addressFk - ) sub ON sub.Id_Consigna = mt.Id_Consigna + GROUP BY t.addressFk + ) sub ON sub.Id_Consigna = mt.addressFk SET mt.priority = sub.Prioridad WHERE mt.routeFk = vRutaId; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index 07cff3ff5..ea1dc8e7d 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -11,7 +11,7 @@ BEGIN JOIN Clientes c ON c.Id_Cliente = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( - Fecha BETWEEN util.today() AND vEndingDate + t.shipped BETWEEN util.today() AND vEndingDate OR ( ts.alertLevel < 3 AND t.shipped >= vStartingDate diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index bb3c1028c..148379a64 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -38,8 +38,8 @@ BEGIN JOIN vn.ticket t on m.Id_Ticket = t.id JOIN tmp.client_list c on c.Id_Cliente = t.clientFk JOIN vn.client cl ON cl.id = t.clientFk - WHERE Factura IS NULL - AND Fecha BETWEEN startingDate AND endingDate + WHERE t.refFk IS NULL + AND t.shipped BETWEEN startingDate AND endingDate GROUP BY t.clientFk; DROP TEMPORARY TABLE IF EXISTS tmp.risk; From be4403819da7c94d8514b48e859422483b3175d2 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:45:14 +0100 Subject: [PATCH 07/78] feat: refs #6777 --- db/routines/bs/procedures/ventas_contables_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 955356d4e..7c8063e56 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, t.companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month From 311401daba314635241aa7eed2513db509e767f5 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 08:59:25 +0100 Subject: [PATCH 08/78] fix: refs #6777 ticketMRW --- db/routines/vn/views/ticketMRW.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index 2677b41e7..26b928ac4 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -44,4 +44,4 @@ FROM ( ) ) JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ) + ); From 624c214178c1c7671df2515388187b545f7c66da Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 10:46:08 +0100 Subject: [PATCH 09/78] fix: refs #6777 Fixed version --- .../10921-bronzeAralia/00-firstScript.sql | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql new file mode 100644 index 000000000..55aa03dca --- /dev/null +++ b/db/versions/10921-bronzeAralia/00-firstScript.sql @@ -0,0 +1,49 @@ +-- Para evitar el error al hacer myt run +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Clientes` +AS SELECT `c`.`id` AS `id_cliente`, + `c`.`name` AS `cliente`, + `c`.`fi` AS `if`, + `c`.`socialName` AS `razonSocial`, + `c`.`contact` AS `contacto`, + `c`.`street` AS `domicilio`, + `c`.`city` AS `poblacion`, + `c`.`postcode` AS `codPostal`, + `c`.`phone` AS `telefono`, + `c`.`mobile` AS `movil`, + `c`.`isRelevant` AS `real`, + `c`.`email` AS `e-mail`, + `c`.`iban` AS `iban`, + `c`.`dueDay` AS `vencimiento`, + `c`.`accountingAccount` AS `Cuenta`, + `c`.`isEqualizated` AS `RE`, + `c`.`provinceFk` AS `province_id`, + `c`.`hasToInvoice` AS `invoice`, + `c`.`credit` AS `credito`, + `c`.`countryFk` AS `Id_Pais`, + `c`.`isActive` AS `activo`, + `c`.`gestdocFk` AS `gestdoc_id`, + `c`.`quality` AS `calidad`, + `c`.`payMethodFk` AS `pay_met_id`, + `c`.`created` AS `created`, + `c`.`isToBeMailed` AS `mail`, + `c`.`contactChannelFk` AS `chanel_id`, + `c`.`hasSepaVnl` AS `sepaVnl`, + `c`.`hasCoreVnl` AS `coreVnl`, + `c`.`hasCoreVnh` AS `coreVnh`, + `c`.`hasLcr` AS `hasLcr`, + `c`.`defaultAddressFk` AS `default_address`, + `c`.`riskCalculated` AS `risk_calculated`, + `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, + `c`.`isTaxDataChecked` AS `contabilizado`, + `c`.`isFreezed` AS `congelado`, + `c`.`creditInsurance` AS `creditInsurance`, + `c`.`isCreatedAsServed` AS `isCreatedAsServed`, + `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`; \ No newline at end of file From e047d445d3fbf7d4bbf1d983178e749ebb0f2be6 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Thu, 29 Feb 2024 12:00:43 +0100 Subject: [PATCH 10/78] feat: refs#6493 modificado entry_getTransfer --- db/routines/vn/procedures/entry_getTransfer.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index 151bebd4d..89ad5a67f 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -68,19 +68,19 @@ BEGIN AND v.`visible` ON DUPLICATE KEY UPDATE visibleLanding = v.`visible`; - CALL vn2008.availableTraslate(vWarehouseOut, vDateShipped, NULL); + CALL vn.available_traslate(vWarehouseOut, vDateShipped, NULL); INSERT INTO tItem(itemFk, available) SELECT a.item_id, a.available - FROM vn2008.availableTraslate a + FROM availableTraslate a WHERE a.available ON DUPLICATE KEY UPDATE available = a.available; - CALL vn2008.availableTraslate(vWarehouseIn, vDateLanded, vWarehouseOut); + CALL vn.available_traslate(vWarehouseIn, vDateLanded, vWarehouseOut); INSERT INTO tItem(itemFk, availableLanding) SELECT a.item_id, a.available - FROM vn2008.availableTraslate a + FROM availableTraslate a WHERE a.available ON DUPLICATE KEY UPDATE availableLanding = a.available; ELSE From c889353459afd15e3c1ac54423d8dc57fc11c0ad Mon Sep 17 00:00:00 2001 From: Jbreso Date: Fri, 1 Mar 2024 14:37:14 +0100 Subject: [PATCH 11/78] feat: refs#6493 modificar procedimiento balance_create --- db/routines/vn/procedures/balance_create.sql | 96 ++++---- .../vn2008/procedures/availableTraslate.sql | 126 ----------- .../vn2008/procedures/balance_create.sql | 207 ------------------ 3 files changed, 49 insertions(+), 380 deletions(-) delete mode 100644 db/routines/vn2008/procedures/availableTraslate.sql delete mode 100644 db/routines/vn2008/procedures/balance_create.sql diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 9c22a4fd4..9fb8b614c 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -18,7 +18,7 @@ BEGIN DECLARE vStartingYear INT DEFAULT vCurYear - 2; DECLARE vTable TEXT; - SET vTable = util.quoteIdentifier('balance_nest_tree'); + SET vTable = util.quoteIdentifier('balanceNestTree'); SET vYear = util.quoteIdentifier(vCurYear); SET vOneYearAgo = util.quoteIdentifier(vCurYear-1); SET vTwoYearsAgo = util.quoteIdentifier(vCurYear-2); @@ -44,67 +44,65 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.balance SELECT * FROM tmp.nest; - DROP TEMPORARY TABLE IF EXISTS tmp.empresas_receptoras; - DROP TEMPORARY TABLE IF EXISTS tmp.empresas_emisoras; - - SELECT companyGroupFk INTO vConsolidatedGroup + SELECT companyGroupFk INTO vConsolidatedGroup FROM company WHERE id = vCompany; - CREATE OR REPLACE TEMPORARY TABLE tmp.empresas_receptoras - SELECT id empresa_id + CREATE OR REPLACE TEMPORARY TABLE tCompanyReceiving + SELECT id companyId FROM company WHERE id = vCompany OR companyGroupFk = IF(vIsConsolidated, vConsolidatedGroup, NULL); - CREATE OR REPLACE TEMPORARY TABLE tmp.empresas_emisoras - SELECT id empresa_id FROM supplier p; + CREATE OR REPLACE TEMPORARY TABLE tCompanyIssuing + SELECT id companyId + FROM supplier p; IF vInterGroupSalesIncluded = FALSE THEN - DELETE ee.* - FROM tmp.empresas_emisoras ee - JOIN company e on e.id = ee.empresa_id + DELETE ci.* + FROM tCompanyIssuing ci + JOIN company e on e.id = ci.companyId WHERE e.companyGroupFk = vConsolidatedGroup; END IF; -- Se calculan las facturas que intervienen, para luego poder servir el desglose desde aqui - CREATE OR REPLACE TEMPORARY TABLE tmp.balance_desglose - SELECT er.empresa_id receptora_id, - ee.empresa_id emisora_id, + CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail + SELECT cr.companyId receivingId, + ci.companyId issuingId, year(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`, month(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`, - expenseFk Id_Gasto, - SUM(bi) importe + expenseFk, + SUM(taxableBase) amount FROM invoiceIn r JOIN invoiceInTax ri on ri.invoiceInFk = r.id - JOIN tmp.empresas_receptoras er on er.empresa_id = r.companyFk - JOIN tmp.empresas_emisoras ee ON ee.empresa_id = r.supplierFk + JOIN tCompanyReceiving cr on cr.companyId = r.companyFk + JOIN tCompanyIssuing ci ON ci.companyId = r.supplierFk WHERE IFNULL(r.bookEntried,IFNULL(r.booked, r.issued)) >= vStartingDate AND r.isBooked - GROUP BY Id_Gasto, year, month, emisora_id, receptora_id; + GROUP BY expenseFk, year, month, ci.companyId, cr.companyId; - INSERT INTO tmp.balance_desglose( - receptora_id, - emisora_id, + INSERT INTO tmp.balanceDetail( + receivingId, + issuingId, year, month, - Id_Gasto, - importe) - SELECT gr.empresa_id, - gr.empresa_id, + expenseFk, + amount) + SELECT em.companyFk, + em.companyFk, year, month, - Id_Gasto, - SUM(importe) - FROM vn2008.gastos_resumen gr - JOIN tmp.empresas_receptoras er on gr.empresa_id = er.empresa_id + expenseFk, + SUM(amount) + FROM expenseManual em + JOIN tCompanyReceiving er on em.companyFk = em.companyFk WHERE year >= vStartingYear AND month BETWEEN vStartingMonth AND vEndingMonth - GROUP BY Id_Gasto, year, month, gr.empresa_id; + GROUP BY expenseFk, year, month, em.companyFk; - DELETE FROM tmp.balance_desglose + DELETE FROM tmp.balanceDetail WHERE month < vStartingMonth OR month > vEndingMonth; @@ -114,29 +112,29 @@ BEGIN ADD COLUMN ', vTwoYearsAgo ,' INT(10) NULL , ADD COLUMN ', vOneYearAgo ,' INT(10) NULL , ADD COLUMN ', vYear,' INT(10) NULL , - ADD COLUMN Id_Gasto VARCHAR(10) NULL, - ADD COLUMN Gasto VARCHAR(45) NULL'); + ADD COLUMN expenseFk VARCHAR(10) NULL, + ADD COLUMN expenseName VARCHAR(45) NULL'); -- Añadimos los gastos, para facilitar el formulario UPDATE tmp.balance b - JOIN vn2008.balance_nest_tree bnt on bnt.id = b.id + JOIN balanceNestTree bnt on bnt.id = b.id JOIN (SELECT id, name FROM expense - GROUP BY id) g ON g.id = bnt.Id_Gasto COLLATE utf8_general_ci - SET b.Id_Gasto = g.id COLLATE utf8_general_ci - , b.Gasto = g.id COLLATE utf8_general_ci ; + GROUP BY id) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci + SET b.expenseFk = g.id COLLATE utf8_general_ci + , b.expenseName = g.id COLLATE utf8_general_ci ; -- Rellenamos los valores de primer nivel, los que corresponden a los gastos simples WHILE vYears >= 0 DO SET vQuery = CONCAT( 'UPDATE tmp.balance b JOIN - (SELECT Id_Gasto, SUM(Importe) as Importe - FROM tmp.balance_desglose + (SELECT expenseFk, SUM(amount) as amount + FROM tmp.balanceDetail WHERE year = ? - GROUP BY Id_Gasto - ) sub on sub.Id_Gasto = b.Id_Gasto COLLATE utf8_general_ci - SET ', util.quoteIdentifier(vCurYear - vYears), ' = - Importe'); + GROUP BY expenseFk + ) sub on sub.expenseFk = b.expenseFk COLLATE utf8_general_ci + SET ', util.quoteIdentifier(vCurYear - vYears), ' = - amount'); EXECUTE IMMEDIATE vQuery USING vCurYear - vYears; @@ -153,10 +151,10 @@ BEGIN SUM(IF(year = ?, venta, 0)) y0, c.Gasto FROM bs.ventas_contables c - JOIN tmp.empresas_receptoras er on er.empresa_id = c.empresa_id + JOIN tCompanyReceiving cr on cr.companyId = c.empresa_id WHERE month BETWEEN ? AND ? GROUP BY c.Gasto - ) sub ON sub.Gasto = b.Id_Gasto COLLATE utf8_general_ci + ) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci SET b.', vTwoYearsAgo, '= IFNULL(b.', vTwoYearsAgo, ', 0) + sub.y2, b.', vOneYearAgo, '= IFNULL(b.', vOneYearAgo, ', 0) + sub.y1, b.', vYear, '= IFNULL(b.', vYear, ', 0) + sub.y0') @@ -198,7 +196,11 @@ BEGIN b.', vOneYearAgo, ' = oneYearAgo, b.', vTwoYearsAgo, ' = twoYearsAgo'); - SELECT *, CONCAT('',ifnull(Id_Gasto,'')) newgasto + SELECT *, CONCAT('',ifnull(expenseFk,'')) newgasto FROM tmp.balance; + + DROP TEMPORARY TABLE IF EXISTS tCompanyReceiving; + DROP TEMPORARY TABLE IF EXISTS tCompanyIssuing; + END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql deleted file mode 100644 index a3d2c8bea..000000000 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ /dev/null @@ -1,126 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`availableTraslate`( - vWarehouseLanding INT, - vDated DATE, - vWarehouseShipment INT) -proc: BEGIN - DECLARE vDatedFrom DATE; - DECLARE vDatedTo DATETIME; - DECLARE vDatedReserve DATETIME; - DECLARE vDatedInventory DATE; - - IF vDated < util.VN_CURDATE() THEN - LEAVE proc; - END IF; - - CALL vn.item_getStock (vWarehouseLanding, vDated, NULL); - - -- Calcula algunos parámetros necesarios - SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; - SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve - FROM hedera.orderConfig; - - -- Calcula el ultimo dia de vida para cada producto - DROP TEMPORARY TABLE IF EXISTS itemRange; - CREATE TEMPORARY TABLE itemRange - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT c.itemFk, MAX(t.landed) dated - FROM vn.buy c - JOIN vn.entry e ON c.entryFk = e.id - JOIN vn.travel t ON t.id = e.travelFk - JOIN vn.warehouse w ON w.id = t.warehouseInFk - WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom - AND t.warehouseInFk = vWarehouseLanding - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - GROUP BY c.itemFk; - - -- Tabla con el ultimo dia de last_buy para cada producto que hace un replace de la anterior - CALL vn.buyUltimate(vWarehouseShipment, util.VN_CURDATE()); - - INSERT INTO itemRange - SELECT t.itemFk, tr.landed - FROM tmp.buyUltimate t - JOIN vn.buy b ON b.id = t.buyFk - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - LEFT JOIN itemRange i ON t.itemFk = i.itemFk - WHERE t.warehouseFk = vWarehouseShipment - AND NOT e.isRaid - ON DUPLICATE KEY UPDATE itemRange.dated = GREATEST(itemRange.dated, tr.landed); - - DROP TEMPORARY TABLE IF EXISTS itemRangeLive; - CREATE TEMPORARY TABLE itemRangeLive - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT ir.itemFk, TIMESTAMP(TIMESTAMPADD(DAY, it.life, ir.dated), '23:59:59') dated - FROM itemRange ir - JOIN vn.item i ON i.id = ir.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - HAVING dated >= vDatedFrom OR dated IS NULL; - - -- Calcula el ATP - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc - (INDEX (itemFk,warehouseFk)) - ENGINE = MEMORY - SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity - FROM vn.itemTicketOut i - JOIN itemRangeLive ir ON ir.itemFK = i.itemFk - WHERE i.shipped >= vDatedFrom - AND (ir.dated IS NULL OR i.shipped <= ir.dated) - AND i.warehouseFk = vWarehouseLanding - UNION ALL - SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity - FROM vn.buy b - JOIN vn.entry e ON b.entryFk = e.id - JOIN vn.travel t ON t.id = e.travelFk - JOIN itemRangeLive ir ON ir.itemFk = b.itemFk - WHERE NOT e.isExcludedFromAvailable - AND b.quantity <> 0 - AND NOT e.isRaid - AND t.warehouseInFk = vWarehouseLanding - AND t.landed >= vDatedFrom - AND (ir.dated IS NULL OR t.landed <= ir.dated) - UNION ALL - SELECT i.itemFk, vWarehouseLanding, i.shipped, i.quantity - FROM vn.itemEntryOut i - JOIN itemRangeLive ir ON ir.itemFk = i.itemFk - WHERE i.shipped >= vDatedFrom - AND (ir.dated IS NULL OR i.shipped <= ir.dated) - AND i.warehouseOutFk = vWarehouseLanding - UNION ALL - SELECT r.item_id, vWarehouseLanding, r.shipment, -r.amount - FROM hedera.order_row r - JOIN hedera.`order` o ON o.id = r.order_id - JOIN itemRangeLive ir ON ir.itemFk = r.item_id - WHERE r.shipment >= vDatedFrom - AND (ir.dated IS NULL OR r.shipment <= ir.dated) - AND r.warehouse_id = vWarehouseLanding - AND r.created >= vDatedReserve - AND NOT o.confirmed; - - CALL vn.item_getAtp(vDated); - - DROP TEMPORARY TABLE IF EXISTS availableTraslate; - CREATE TEMPORARY TABLE availableTraslate - (PRIMARY KEY (item_id)) - ENGINE = MEMORY - SELECT t.item_id, SUM(stock) available - FROM ( - SELECT ti.itemFk item_id, stock - FROM tmp.itemList ti - JOIN itemRange ir ON ir.itemFk = ti.itemFk - UNION ALL - SELECT itemFk, quantity - FROM tmp.itemAtp - ) t - GROUP BY t.item_id - HAVING available <> 0; - - DROP TEMPORARY TABLE tmp.itemList, itemRange, itemRangeLive; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/balance_create.sql b/db/routines/vn2008/procedures/balance_create.sql deleted file mode 100644 index 2acd26834..000000000 --- a/db/routines/vn2008/procedures/balance_create.sql +++ /dev/null @@ -1,207 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`balance_create`( - IN vStartingMonth INT, - IN vEndingMonth INT, - IN vCompany INT, - IN vIsConsolidated BOOLEAN, - IN vInterGroupSalesIncluded BOOLEAN) -BEGIN - DECLARE intGAP INT DEFAULT 7; - DECLARE vYears INT DEFAULT 2; - DECLARE vYear TEXT; - DECLARE vOneYearAgo TEXT; - DECLARE vTwoYearsAgo TEXT; - DECLARE vQuery TEXT; - DECLARE vConsolidatedGroup INT; - DECLARE vStartingDate DATE DEFAULT '2020-01-01'; - DECLARE vCurYear INT DEFAULT YEAR(util.VN_CURDATE()); - DECLARE vStartingYear INT DEFAULT vCurYear - 2; - DECLARE vTable TEXT; - - SET vTable = util.quoteIdentifier('balance_nest_tree'); - SET vYear = util.quoteIdentifier(vCurYear); - SET vOneYearAgo = util.quoteIdentifier(vCurYear-1); - SET vTwoYearsAgo = util.quoteIdentifier(vCurYear-2); - - -- Solicitamos la tabla tmp.nest, como base para el balance - DROP TEMPORARY TABLE IF EXISTS tmp.nest; - - EXECUTE IMMEDIATE CONCAT( - 'CREATE TEMPORARY TABLE tmp.nest - SELECT node.id - ,CONCAT( REPEAT(REPEAT(" ",?), COUNT(parent.id) - 1), node.name) AS name - ,node.lft - ,node.rgt - ,COUNT(parent.id) - 1 as depth - ,cast((node.rgt - node.lft - 1) / 2 as DECIMAL) as sons - FROM ', vTable, ' AS node, - ', vTable, ' AS parent - WHERE node.lft BETWEEN parent.lft AND parent.rgt - GROUP BY node.id - ORDER BY node.lft') - USING intGAP; - - DROP TEMPORARY TABLE IF EXISTS tmp.balance; - CREATE TEMPORARY TABLE tmp.balance - SELECT * FROM tmp.nest; - - DROP TEMPORARY TABLE IF EXISTS tmp.empresas_receptoras; - DROP TEMPORARY TABLE IF EXISTS tmp.empresas_emisoras; - - SELECT empresa_grupo INTO vConsolidatedGroup - FROM empresa - WHERE id = vCompany; - - CREATE TEMPORARY TABLE tmp.empresas_receptoras - SELECT id as empresa_id - FROM vn2008.empresa - WHERE id = vCompany - OR empresa_grupo = IF(vIsConsolidated, vConsolidatedGroup, NULL); - - CREATE TEMPORARY TABLE tmp.empresas_emisoras - SELECT Id_Proveedor as empresa_id FROM vn2008.Proveedores p; - - IF vInterGroupSalesIncluded = FALSE THEN - - DELETE ee.* - FROM tmp.empresas_emisoras ee - JOIN vn2008.empresa e on e.id = ee.empresa_id - WHERE e.empresa_grupo = vConsolidatedGroup; - - END IF; - - -- Se calculan las facturas que intervienen, para luego poder servir el desglose desde aqui - DROP TEMPORARY TABLE IF EXISTS tmp.balance_desglose; - CREATE TEMPORARY TABLE tmp.balance_desglose - SELECT er.empresa_id receptora_id, - ee.empresa_id emisora_id, - year(IFNULL(r.bookEntried,IFNULL(r.dateBooking, r.Fecha))) `year`, - month(IFNULL(r.bookEntried,IFNULL(r.dateBooking, r.Fecha))) `month`, - gastos_id Id_Gasto, - SUM(bi) importe - FROM recibida r - JOIN recibida_iva ri on ri.recibida_id = r.id - JOIN tmp.empresas_receptoras er on er.empresa_id = r.empresa_id - JOIN tmp.empresas_emisoras ee ON ee.empresa_id = r.proveedor_id - WHERE IFNULL(r.bookEntried,IFNULL(r.dateBooking, r.Fecha)) >= vStartingDate - AND r.contabilizada - GROUP BY Id_Gasto, year, month, emisora_id, receptora_id; - - INSERT INTO tmp.balance_desglose( - receptora_id, - emisora_id, - year, - month, - Id_Gasto, - importe) - SELECT gr.empresa_id, - gr.empresa_id, - year, - month, - Id_Gasto, - SUM(importe) - FROM gastos_resumen gr - JOIN tmp.empresas_receptoras er on gr.empresa_id = er.empresa_id - WHERE year >= vStartingYear - AND month BETWEEN vStartingMonth AND vEndingMonth - GROUP BY Id_Gasto, year, month, gr.empresa_id; - - DELETE FROM tmp.balance_desglose - WHERE month < vStartingMonth - OR month > vEndingMonth; - - -- Ahora el balance - EXECUTE IMMEDIATE CONCAT( - 'ALTER TABLE tmp.balance - ADD COLUMN ', vTwoYearsAgo ,' INT(10) NULL , - ADD COLUMN ', vOneYearAgo ,' INT(10) NULL , - ADD COLUMN ', vYear,' INT(10) NULL , - ADD COLUMN Id_Gasto VARCHAR(10) NULL, - ADD COLUMN Gasto VARCHAR(45) NULL'); - - -- Añadimos los gastos, para facilitar el formulario - UPDATE tmp.balance b - JOIN vn2008.balance_nest_tree bnt on bnt.id = b.id - JOIN (SELECT id Id_Gasto, name Gasto - FROM vn.expense - GROUP BY id) g ON g.Id_Gasto = bnt.Id_Gasto COLLATE utf8_general_ci - SET b.Id_Gasto = g.Id_Gasto COLLATE utf8_general_ci - , b.Gasto = g.Gasto COLLATE utf8_general_ci ; - - -- Rellenamos los valores de primer nivel, los que corresponden a los gastos simples - WHILE vYears >= 0 DO - SET vQuery = CONCAT( - 'UPDATE tmp.balance b - JOIN - (SELECT Id_Gasto, SUM(Importe) as Importe - FROM tmp.balance_desglose - WHERE year = ? - GROUP BY Id_Gasto - ) sub on sub.Id_Gasto = b.Id_Gasto COLLATE utf8_general_ci - SET ', util.quoteIdentifier(vCurYear - vYears), ' = - Importe'); - - EXECUTE IMMEDIATE vQuery - USING vCurYear - vYears; - - SET vYears = vYears - 1; - END WHILE; - - -- Añadimos las ventas - EXECUTE IMMEDIATE CONCAT( - 'UPDATE tmp.balance b - JOIN ( - SELECT SUM(IF(year = ?, venta, 0)) y2, - SUM(IF(year = ?, venta, 0)) y1, - SUM(IF(year = ?, venta, 0)) y0, - c.Gasto - FROM bs.ventas_contables c - JOIN tmp.empresas_receptoras er on er.empresa_id = c.empresa_id - WHERE month BETWEEN ? AND ? - GROUP BY c.Gasto - ) sub ON sub.Gasto = b.Id_Gasto COLLATE utf8_general_ci - SET b.', vTwoYearsAgo, '= IFNULL(b.', vTwoYearsAgo, ', 0) + sub.y2, - b.', vOneYearAgo, '= IFNULL(b.', vOneYearAgo, ', 0) + sub.y1, - b.', vYear, '= IFNULL(b.', vYear, ', 0) + sub.y0') - USING vCurYear-2, - vCurYear-1, - vCurYear, - vStartingMonth, - vEndingMonth; - - -- Ventas intra grupo - IF NOT vInterGroupSalesIncluded THEN - - SELECT lft, rgt INTO @grupoLft, @grupoRgt - FROM tmp.balance b - WHERE TRIM(b.`name`) = 'Grupo'; - - DELETE - FROM tmp.balance - WHERE lft BETWEEN @grupoLft AND @grupoRgt; - - END IF; - - -- Rellenamos el valor de los padres con la suma de los hijos - DROP TEMPORARY TABLE IF EXISTS tmp.balance_aux; - CREATE TEMPORARY TABLE tmp.balance_aux - SELECT * FROM tmp.balance; - - EXECUTE IMMEDIATE - CONCAT('UPDATE tmp.balance b - JOIN ( - SELECT b1.id, - b1.name, - SUM(b2.', vYear,') thisYear, - SUM(b2.', vOneYearAgo,') oneYearAgo, - SUM(b2.', vTwoYearsAgo,') twoYearsAgo - FROM tmp.nest b1 - JOIN tmp.balance_aux b2 on b2.lft BETWEEN b1.lft and b1.rgt - GROUP BY b1.id)sub ON sub.id = b.id - SET b.', vYear, ' = thisYear, - b.', vOneYearAgo, ' = oneYearAgo, - b.', vTwoYearsAgo, ' = twoYearsAgo'); - - SELECT *, CONCAT('',ifnull(Id_Gasto,'')) newgasto - FROM tmp.balance; -END$$ -DELIMITER ; From 052acdcc0874f36b2e5e1913eca080c243a75126 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 13 Mar 2024 13:20:14 +0100 Subject: [PATCH 12/78] feat: refs #7029 packaging --- db/versions/10950-greenArborvitae/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/10950-greenArborvitae/00-firstScript.sql diff --git a/db/versions/10950-greenArborvitae/00-firstScript.sql b/db/versions/10950-greenArborvitae/00-firstScript.sql new file mode 100644 index 000000000..e8d4e31f2 --- /dev/null +++ b/db/versions/10950-greenArborvitae/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.packaging +MODIFY COLUMN volume decimal(10,2) CHECK (volume >= COALESCE(width, 1) * COALESCE(depth, 1) * COALESCE(height, 1)); From f2a1d401ca6abe74dba801987fab8de285dc1527 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Fri, 22 Mar 2024 08:32:38 +0100 Subject: [PATCH 13/78] refs#6493 update --- db/routines/vn/procedures/available_traslate.sql | 2 +- db/routines/vn/procedures/entry_getTransfer.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 44b76d0c2..ad442a724 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -103,7 +103,7 @@ proc: BEGIN CALL item_getAtp(vDated); - CREATE OR REPLACE TEMPORARY TABLE availableTraslate + CREATE OR REPLACE TEMPORARY TABLE tmp.availableTraslate (PRIMARY KEY (item_id)) ENGINE = MEMORY SELECT t.item_id, SUM(stock) available diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index e7ddcea31..165c87dc7 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -68,19 +68,19 @@ BEGIN AND v.`visible` ON DUPLICATE KEY UPDATE visibleLanding = v.`visible`; - CALL vn.available_traslate(vWarehouseOut, vDateShipped, NULL); + CALL available_traslate(vWarehouseOut, vDateShipped, NULL); INSERT INTO tItem(itemFk, available) SELECT a.item_id, a.available - FROM availableTraslate a + FROM tmp.availableTraslate a WHERE a.available ON DUPLICATE KEY UPDATE available = a.available; - CALL vn.available_traslate(vWarehouseIn, vDateLanded, vWarehouseOut); + CALL available_traslate(vWarehouseIn, vDateLanded, vWarehouseOut); INSERT INTO tItem(itemFk, availableLanding) SELECT a.item_id, a.available - FROM availableTraslate a + FROM tmp.availableTraslate a WHERE a.available ON DUPLICATE KEY UPDATE availableLanding = a.available; ELSE From f4b50dec3e04d0f5a701dc1e8bce1321b0c8e36e Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 25 Mar 2024 09:41:16 +0100 Subject: [PATCH 14/78] feat: refs#6493 modificar procedimiento balance_create --- db/routines/vn/procedures/balance_create.sql | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 9fb8b614c..a3f498661 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -6,6 +6,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`( IN vIsConsolidated BOOLEAN, IN vInterGroupSalesIncluded BOOLEAN) BEGIN +/** + * Crea un balance financiero para una empresa durante un período de tiempo determinado + * + * @param vStartingMonth Mes de inicio del período + * @param vEndingMonth Mes de finalización del período + * @param vCompany Identificador de la empresa + * @param vIsConsolidated Indica si se trata de un balance consolidado + * @param vInterGroupSalesIncluded Indica si se incluyen las ventas dentro del grupo + */ DECLARE intGAP INT DEFAULT 7; DECLARE vYears INT DEFAULT 2; DECLARE vYear TEXT; @@ -71,8 +80,8 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail SELECT cr.companyId receivingId, ci.companyId issuingId, - year(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`, - month(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`, + YEAR(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`, + MONTH(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`, expenseFk, SUM(taxableBase) amount FROM invoiceIn r @@ -129,7 +138,7 @@ BEGIN SET vQuery = CONCAT( 'UPDATE tmp.balance b JOIN - (SELECT expenseFk, SUM(amount) as amount + (SELECT expenseFk, SUM(amount) FROM tmp.balanceDetail WHERE year = ? GROUP BY expenseFk @@ -151,7 +160,7 @@ BEGIN SUM(IF(year = ?, venta, 0)) y0, c.Gasto FROM bs.ventas_contables c - JOIN tCompanyReceiving cr on cr.companyId = c.empresa_id + JOIN tCompanyReceiving cr ON cr.companyId = c.empresa_id WHERE month BETWEEN ? AND ? GROUP BY c.Gasto ) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci From 46f60615bd9a78df72488252e70dda9e4bda0f0a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Thu, 28 Mar 2024 14:27:29 +0100 Subject: [PATCH 15/78] feat: refs#6493 modificar procedimiento available_traslate --- db/routines/vn/procedures/available_traslate.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index ad442a724..cd472fdbd 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -4,6 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`available_traslate` vDated DATE, vWarehouseShipment INT) proc: BEGIN +/** + * Calcular la disponibilidad dependiendo del almacen de origen y destino según la fecha + * + * @param vWarehouseLanding almacén de llegada. + * @param vDated la fecha para la cual se está calculando la disponibilidad de articulos. + * @param vWarehouseShipment almacén de destino. + */ DECLARE vDatedFrom DATE; DECLARE vDatedTo DATETIME; DECLARE vDatedReserve DATETIME; From 4389cd5d746bc4ec2548f6474b5da45b37a40854 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 2 Apr 2024 09:56:46 +0200 Subject: [PATCH 16/78] feat: refs#6493 modificar procedimiento available_traslate --- .../vn/procedures/available_traslate.sql | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index cd472fdbd..3638329bb 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -72,12 +72,12 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk,warehouseFk)) ENGINE = MEMORY - SELECT i.item_id itemFk, vWarehouseLanding warehouseFk, i.dat dated, i.amount quantity - FROM vn2008.item_out i + SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity + FROM vn.itemTicketOut i JOIN tItemRangeLive ir ON ir.itemFK = i.item_id - WHERE i.dat >= vDatedFrom - AND (ir.dated IS NULL OR i.dat <= ir.dated) - AND i.warehouse_id = vWarehouseLanding + WHERE i.shipped >= vDatedFrom + AND (ir.dated IS NULL OR i.shipped <= ir.dated) + AND i.warehouseFk = vWarehouseLanding UNION ALL SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity FROM buy b @@ -91,12 +91,12 @@ proc: BEGIN AND t.landed >= vDatedFrom AND (ir.dated IS NULL OR t.landed <= ir.dated) UNION ALL - SELECT i.item_id, vWarehouseLanding, i.dat, i.amount - FROM vn2008.item_entry_out i - JOIN tItemRangeLive ir ON ir.itemFk = i.item_id - WHERE i.dat >= vDatedFrom - AND (ir.dated IS NULL OR i.dat <= ir.dated) - AND i.warehouse_id = vWarehouseLanding + SELECT i.itemFk, vWarehouseLanding, i.shipped, i.quantity + FROM vn.itemEntryOut i + JOIN tItemRangeLive ir ON ir.itemFk = i.itemFk + WHERE i.shipped >= vDatedFrom + AND (ir.dated IS NULL OR i.shipped <= ir.dated) + AND i.warehouseOutFk = vWarehouseLanding UNION ALL SELECT r.item_id, vWarehouseLanding, r.shipment, -r.amount FROM hedera.order_row r From c74aea74bca2ce34b2afa723adac0e2810b5f82a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Fri, 5 Apr 2024 12:58:31 +0200 Subject: [PATCH 17/78] feat: refs#6493 modificaciones solicitadas. --- .../vn/procedures/available_traslate.sql | 9 +++--- db/routines/vn/procedures/balance_create.sql | 28 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 3638329bb..337aeae27 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -22,7 +22,6 @@ proc: BEGIN CALL item_getStock (vWarehouseLanding, vDated, NULL); - -- Calcula algunos parámetros necesarios SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); @@ -62,7 +61,7 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tItemRangeLive (PRIMARY KEY (itemFk)) ENGINE = MEMORY - SELECT ir.itemFk, TIMESTAMP(TIMESTAMPADD(DAY, it.life, ir.dated), '23:59:59') dated + SELECT ir.itemFk, TIMESTAMP(ir.dated + INTERVAL it.life DAY, '23:59:59') dated FROM tItemRange ir JOIN item i ON i.id = ir.itemFk JOIN itemType it ON it.id = i.typeFk @@ -73,8 +72,8 @@ proc: BEGIN (INDEX (itemFk,warehouseFk)) ENGINE = MEMORY SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity - FROM vn.itemTicketOut i - JOIN tItemRangeLive ir ON ir.itemFK = i.item_id + FROM itemTicketOut i + JOIN tItemRangeLive ir ON ir.itemFK = i.itemFk WHERE i.shipped >= vDatedFrom AND (ir.dated IS NULL OR i.shipped <= ir.dated) AND i.warehouseFk = vWarehouseLanding @@ -92,7 +91,7 @@ proc: BEGIN AND (ir.dated IS NULL OR t.landed <= ir.dated) UNION ALL SELECT i.itemFk, vWarehouseLanding, i.shipped, i.quantity - FROM vn.itemEntryOut i + FROM itemEntryOut i JOIN tItemRangeLive ir ON ir.itemFk = i.itemFk WHERE i.shipped >= vDatedFrom AND (ir.dated IS NULL OR i.shipped <= ir.dated) diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index a3f498661..ea773759a 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -58,39 +58,39 @@ BEGIN WHERE id = vCompany; CREATE OR REPLACE TEMPORARY TABLE tCompanyReceiving - SELECT id companyId + SELECT id companyFk FROM company WHERE id = vCompany OR companyGroupFk = IF(vIsConsolidated, vConsolidatedGroup, NULL); CREATE OR REPLACE TEMPORARY TABLE tCompanyIssuing - SELECT id companyId + SELECT id companyFk FROM supplier p; IF vInterGroupSalesIncluded = FALSE THEN DELETE ci.* FROM tCompanyIssuing ci - JOIN company e on e.id = ci.companyId + JOIN company e on e.id = ci.companyFk WHERE e.companyGroupFk = vConsolidatedGroup; END IF; -- Se calculan las facturas que intervienen, para luego poder servir el desglose desde aqui CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail - SELECT cr.companyId receivingId, - ci.companyId issuingId, + SELECT cr.companyFk receivingId, + ci.companyFk issuingId, YEAR(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`, MONTH(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`, expenseFk, SUM(taxableBase) amount FROM invoiceIn r JOIN invoiceInTax ri on ri.invoiceInFk = r.id - JOIN tCompanyReceiving cr on cr.companyId = r.companyFk - JOIN tCompanyIssuing ci ON ci.companyId = r.supplierFk - WHERE IFNULL(r.bookEntried,IFNULL(r.booked, r.issued)) >= vStartingDate + JOIN tCompanyReceiving cr on cr.companyFk = r.companyFk + JOIN tCompanyIssuing ci ON ci.companyFk = r.supplierFk + WHERE COALESCE(r.bookEntried, r.booked, r.issued) >= vStartingDate AND r.isBooked - GROUP BY expenseFk, year, month, ci.companyId, cr.companyId; + GROUP BY expenseFk, year, month, ci.companyFk, cr.companyFk; INSERT INTO tmp.balanceDetail( receivingId, @@ -104,9 +104,9 @@ BEGIN year, month, expenseFk, - SUM(amount) + SUM(em.amount) FROM expenseManual em - JOIN tCompanyReceiving er on em.companyFk = em.companyFk + JOIN tCompanyReceiving er ON er.companyFk = em.companyFk WHERE year >= vStartingYear AND month BETWEEN vStartingMonth AND vEndingMonth GROUP BY expenseFk, year, month, em.companyFk; @@ -138,7 +138,7 @@ BEGIN SET vQuery = CONCAT( 'UPDATE tmp.balance b JOIN - (SELECT expenseFk, SUM(amount) + (SELECT expenseFk, SUM(amount) amount FROM tmp.balanceDetail WHERE year = ? GROUP BY expenseFk @@ -160,7 +160,7 @@ BEGIN SUM(IF(year = ?, venta, 0)) y0, c.Gasto FROM bs.ventas_contables c - JOIN tCompanyReceiving cr ON cr.companyId = c.empresa_id + JOIN tCompanyReceiving cr ON cr.companyFk = c.empresa_id WHERE month BETWEEN ? AND ? GROUP BY c.Gasto ) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci @@ -205,7 +205,7 @@ BEGIN b.', vOneYearAgo, ' = oneYearAgo, b.', vTwoYearsAgo, ' = twoYearsAgo'); - SELECT *, CONCAT('',ifnull(expenseFk,'')) newgasto + SELECT *, CONCAT('',IFNULL(expenseFk,'')) newgasto FROM tmp.balance; DROP TEMPORARY TABLE IF EXISTS tCompanyReceiving; From 55949d0979d87f47b4fd8823ec2e7c368877069b Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 8 Apr 2024 07:44:45 +0200 Subject: [PATCH 18/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/available_traslate.sql | 2 +- db/routines/vn/procedures/balance_create.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 337aeae27..8ef452c6f 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -61,7 +61,7 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tItemRangeLive (PRIMARY KEY (itemFk)) ENGINE = MEMORY - SELECT ir.itemFk, TIMESTAMP(ir.dated + INTERVAL it.life DAY, '23:59:59') dated + SELECT ir.itemFk, util.dayEnd(ir.dated + INTERVAL it.life DAY) dated FROM tItemRange ir JOIN item i ON i.id = ir.itemFk JOIN itemType it ON it.id = i.typeFk diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index ea773759a..e02a26ca2 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -54,8 +54,8 @@ BEGIN SELECT * FROM tmp.nest; SELECT companyGroupFk INTO vConsolidatedGroup - FROM company - WHERE id = vCompany; + FROM company + WHERE id = vCompany; CREATE OR REPLACE TEMPORARY TABLE tCompanyReceiving SELECT id companyFk From 283d8b12417e012d72d8267b59bedb1357c6d05c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 8 Apr 2024 09:11:40 +0200 Subject: [PATCH 19/78] feat: refs #4409 Disable old available triggers --- db/.editorconfig | 13 +++++++ .../hedera/procedures/order_requestRecalc.sql | 3 +- .../hedera/triggers/orderRow_afterDelete.sql | 3 +- .../hedera/triggers/orderRow_afterInsert.sql | 3 +- .../hedera/triggers/orderRow_afterUpdate.sql | 5 ++- .../hedera/triggers/order_afterUpdate.sql | 34 +++++++++---------- .../stock/procedures/inbound_addPick.sql | 4 +-- .../stock/procedures/inbound_removePick.sql | 6 ++-- .../procedures/inbound_requestQuantity.sql | 10 +++--- db/routines/stock/procedures/inbound_sync.sql | 10 +++--- db/routines/stock/procedures/log_add.sql | 21 ------------ .../stock/procedures/log_refreshAll.sql | 2 +- .../stock/procedures/log_refreshBuy.sql | 12 +++---- .../stock/procedures/log_refreshOrder.sql | 18 +++++----- .../stock/procedures/log_refreshSale.sql | 30 ++++++++-------- .../stock/procedures/outbound_sync.sql | 4 +-- db/routines/stock/procedures/visible_log.sql | 8 ++--- .../stock/triggers/inbound_afterDelete.sql | 8 ++--- .../stock/triggers/inbound_beforeInsert.sql | 10 +++--- .../stock/triggers/outbound_afterDelete.sql | 8 ++--- .../stock/triggers/outbound_beforeInsert.sql | 10 +++--- .../vn/procedures/ticket_requestRecalc.sql | 3 +- db/routines/vn/triggers/buy_afterDelete.sql | 5 --- db/routines/vn/triggers/buy_afterInsert.sql | 2 -- db/routines/vn/triggers/buy_afterUpdate.sql | 8 ----- db/routines/vn/triggers/entry_afterUpdate.sql | 9 +---- db/routines/vn/triggers/sale_afterDelete.sql | 1 - db/routines/vn/triggers/sale_afterInsert.sql | 1 - db/routines/vn/triggers/sale_afterUpdate.sql | 9 ----- .../vn/triggers/ticket_afterUpdate.sql | 9 +---- .../vn/triggers/travel_afterUpdate.sql | 8 ++--- 31 files changed, 112 insertions(+), 165 deletions(-) create mode 100644 db/.editorconfig delete mode 100644 db/routines/stock/procedures/log_add.sql diff --git a/db/.editorconfig b/db/.editorconfig new file mode 100644 index 000000000..c97043430 --- /dev/null +++ b/db/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql index 4bcb1010e..aae4a0179 100644 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ b/db/routines/hedera/procedures/order_requestRecalc.sql @@ -10,6 +10,7 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO orderRecalc SET orderFk = vSelf; + -- #4409 Deprecated by MyCDC + -- INSERT INTO orderRecalc SET orderFk = vSelf; END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterDelete.sql b/db/routines/hedera/triggers/orderRow_afterDelete.sql index 10b5ae9e3..e22f786c1 100644 --- a/db/routines/hedera/triggers/orderRow_afterDelete.sql +++ b/db/routines/hedera/triggers/orderRow_afterDelete.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterDel AFTER DELETE ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NULL, OLD.id); - CALL order_requestRecalc(OLD.orderFk); + CALL order_requestRecalc(OLD.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql index 7e8d5f341..c95e0bbdc 100644 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterIns AFTER INSERT ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NEW.id, NULL); - CALL order_requestRecalc(NEW.orderFk); + CALL order_requestRecalc(NEW.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterUpdate.sql b/db/routines/hedera/triggers/orderRow_afterUpdate.sql index 33f4ae84e..bce81a8e4 100644 --- a/db/routines/hedera/triggers/orderRow_afterUpdate.sql +++ b/db/routines/hedera/triggers/orderRow_afterUpdate.sql @@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterUpd AFTER UPDATE ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NEW.id, OLD.id); - CALL order_requestRecalc(OLD.orderFk); - CALL order_requestRecalc(NEW.orderFk); + CALL order_requestRecalc(OLD.orderFk); + CALL order_requestRecalc(NEW.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql index a4549549a..da82d242c 100644 --- a/db/routines/hedera/triggers/order_afterUpdate.sql +++ b/db/routines/hedera/triggers/order_afterUpdate.sql @@ -2,23 +2,21 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate` AFTER UPDATE ON `order` FOR EACH ROW -BEGIN - CALL stock.log_add('order', NEW.id, OLD.id); - - IF !(OLD.address_id <=> NEW.address_id) - OR !(OLD.company_id <=> NEW.company_id) - OR !(OLD.customer_id <=> NEW.customer_id) THEN - CALL order_requestRecalc(NEW.id); - END IF; - - IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN - -- Fallo que se actualiza no se sabe como tickets en este cliente - CALL vn.mail_insert( - 'jgallego@verdnatura.es', - 'noreply@verdnatura.es', - 'Actualizada order al address 2850', - CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) - ); - END IF; +BEGIN + IF !(OLD.address_id <=> NEW.address_id) + OR !(OLD.company_id <=> NEW.company_id) + OR !(OLD.customer_id <=> NEW.customer_id) THEN + CALL order_requestRecalc(NEW.id); + END IF; + + IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN + -- Fallo que se actualiza no se sabe como tickets en este cliente + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Actualizada order al address 2850', + CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) + ); + END IF; END$$ DELIMITER ; diff --git a/db/routines/stock/procedures/inbound_addPick.sql b/db/routines/stock/procedures/inbound_addPick.sql index d867b5641..41b93a986 100644 --- a/db/routines/stock/procedures/inbound_addPick.sql +++ b/db/routines/stock/procedures/inbound_addPick.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_addPick`( vSelf INT, - vOutboundFk INT, - vQuantity INT + vOutboundFk INT, + vQuantity INT ) BEGIN INSERT INTO inboundPick diff --git a/db/routines/stock/procedures/inbound_removePick.sql b/db/routines/stock/procedures/inbound_removePick.sql index e125ee8a7..e183e1171 100644 --- a/db/routines/stock/procedures/inbound_removePick.sql +++ b/db/routines/stock/procedures/inbound_removePick.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_removePick`( vSelf INT, - vOutboundFk INT, - vQuantity INT, - vTotalQuantity INT + vOutboundFk INT, + vQuantity INT, + vTotalQuantity INT ) BEGIN IF vQuantity < vTotalQuantity THEN diff --git a/db/routines/stock/procedures/inbound_requestQuantity.sql b/db/routines/stock/procedures/inbound_requestQuantity.sql index 5d814ce2c..1cbc1908b 100644 --- a/db/routines/stock/procedures/inbound_requestQuantity.sql +++ b/db/routines/stock/procedures/inbound_requestQuantity.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_requestQuantity`( vSelf INT, - vRequested INT, - vDated DATETIME, - OUT vSupplied INT) + vRequested INT, + vDated DATETIME, + OUT vSupplied INT) BEGIN /** * Disassociates inbound picks after the given date until the @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSupplied = 0; OPEN vPicks; @@ -45,7 +45,7 @@ BEGIN SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity); SET vSupplied = vSupplied + vPickGranted; CALL inbound_removePick(vSelf, vOutboundFk, vPickGranted, vPickQuantity); - + UPDATE outbound SET isSync = FALSE, lack = lack + vPickGranted diff --git a/db/routines/stock/procedures/inbound_sync.sql b/db/routines/stock/procedures/inbound_sync.sql index fc672d920..77d3e42f7 100644 --- a/db/routines/stock/procedures/inbound_sync.sql +++ b/db/routines/stock/procedures/inbound_sync.sql @@ -23,7 +23,7 @@ BEGIN SELECT id, lack, lack < quantity FROM outbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated >= vDated AND (vExpired IS NULL OR dated < vExpired) ORDER BY dated, created; @@ -51,8 +51,8 @@ BEGIN END IF; SET vSupplied = LEAST(vAvailable, vLack); - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN SET vAvailable = vAvailable - vSupplied; UPDATE outbound SET lack = lack - vSupplied @@ -64,8 +64,8 @@ BEGIN SET vSupplied = vSupplied + vSuppliedFromRequest; SET vAvailable = vAvailable - vSuppliedFromRequest; END IF; - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN CALL inbound_addPick(vSelf, vOutboundFk, vSupplied); END IF; diff --git a/db/routines/stock/procedures/log_add.sql b/db/routines/stock/procedures/log_add.sql deleted file mode 100644 index 2b75c7f72..000000000 --- a/db/routines/stock/procedures/log_add.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255)) -proc: BEGIN - -- XXX: Disabled while testing - LEAVE proc; - - IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vOldId, - operation = 'delete'; - END IF; - - IF vNewId IS NOT NULL THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vNewId, - operation = 'insert'; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/stock/procedures/log_refreshAll.sql b/db/routines/stock/procedures/log_refreshAll.sql index eab91f8e9..3eaad07f2 100644 --- a/db/routines/stock/procedures/log_refreshAll.sql +++ b/db/routines/stock/procedures/log_refreshAll.sql @@ -10,7 +10,7 @@ BEGIN DO RELEASE_LOCK('stock.log_sync'); RESIGNAL; END; - + IF !GET_LOCK('stock.log_sync', 30) THEN CALL util.throw('Lock timeout exceeded'); END IF; diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql index 62fa73435..488c00a28 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshBuy`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues @@ -11,7 +11,7 @@ BEGIN e.id entryFk, t.id travelFk, b.itemFk, - e.isRaid, + e.isRaid, ADDTIME(t.shipped, IFNULL(t.shipmentHour, '00:00:00')) shipped, t.warehouseOutFk, @@ -24,7 +24,7 @@ BEGIN ABS(b.quantity) quantity, b.created, b.quantity > 0 isIn, - t.shipped < vn.getInventoryDate() lessThanInventory + t.shipped < vn.getInventoryDate() lessThanInventory FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel t ON t.id = e.travelFk @@ -52,7 +52,7 @@ BEGIN quantity, IF(isIn, isReceived, isDelivered) AND !isRaid FROM tValues - WHERE isIn OR !lessThanInventory; + WHERE isIn OR !lessThanInventory; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, @@ -67,7 +67,7 @@ BEGIN quantity, IF(isIn, isDelivered, isReceived) AND !isRaid FROM tValues - WHERE !isIn OR !lessThanInventory; + WHERE !isIn OR !lessThanInventory; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshOrder.sql b/db/routines/stock/procedures/log_refreshOrder.sql index 49225ddf0..ce5b31cc8 100644 --- a/db/routines/stock/procedures/log_refreshOrder.sql +++ b/db/routines/stock/procedures/log_refreshOrder.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshOrder`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DECLARE vExpireTime INT DEFAULT 20; DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT r.id rowFk, @@ -23,24 +23,24 @@ BEGIN OR (vTableName = 'order' AND o.id = vTableId) OR (vTableName = 'orderRow' AND r.id = vTableId) ) - AND !o.confirmed - AND r.shipment >= vn.getInventoryDate() + AND !o.confirmed + AND r.shipment >= vn.getInventoryDate() AND r.created >= vExpired AND r.amount != 0; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, expired, quantity + itemFk, created, expired, quantity ) - SELECT 'orderRow', + SELECT 'orderRow', rowFk, warehouseFk, shipped, itemFk, created, - TIMESTAMPADD(MINUTE, vExpireTime, created), + TIMESTAMPADD(MINUTE, vExpireTime, created), quantity - FROM tValues; + FROM tValues; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql index 0499fc711..983616dca 100644 --- a/db/routines/stock/procedures/log_refreshSale.sql +++ b/db/routines/stock/procedures/log_refreshSale.sql @@ -1,10 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshSale`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT m.id saleFk, @@ -14,7 +14,7 @@ BEGIN t.shipped, ABS(m.quantity) quantity, m.created, - TIMESTAMPADD(DAY, tp.life, t.shipped) expired, + TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, m.isPicked OR s.alertLevel > 1 isPicked FROM vn.sale m @@ -32,33 +32,33 @@ BEGIN REPLACE INTO inbound ( tableName, tableId, warehouseFk, dated, - itemFk, expired, quantity, isPicked + itemFk, expired, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, - expired, + expired, quantity, - isPicked - FROM tValues - WHERE isIn; + isPicked + FROM tValues + WHERE isIn; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, quantity, isPicked + itemFk, created, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, created, quantity, - isPicked - FROM tValues - WHERE !isIn; + isPicked + FROM tValues + WHERE !isIn; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/outbound_sync.sql b/db/routines/stock/procedures/outbound_sync.sql index c79bde45f..0de352176 100644 --- a/db/routines/stock/procedures/outbound_sync.sql +++ b/db/routines/stock/procedures/outbound_sync.sql @@ -7,7 +7,7 @@ BEGIN * @param vSelf The outbound reference */ DECLARE vDated DATETIME; - DECLARE vItem INT; + DECLARE vItem INT; DECLARE vWarehouse INT; DECLARE vLack INT; DECLARE vSupplied INT; @@ -21,7 +21,7 @@ BEGIN SELECT id, available, available < quantity FROM inbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated <= vDated AND (expired IS NULL OR expired > vDated) ORDER BY dated; diff --git a/db/routines/stock/procedures/visible_log.sql b/db/routines/stock/procedures/visible_log.sql index 2867f1186..cc88d3205 100644 --- a/db/routines/stock/procedures/visible_log.sql +++ b/db/routines/stock/procedures/visible_log.sql @@ -1,16 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`visible_log`( vIsPicked BOOL, - vWarehouseFk INT, - vItemFk INT, - vQuantity INT + vWarehouseFk INT, + vItemFk INT, + vQuantity INT ) proc: BEGIN IF !vIsPicked THEN LEAVE proc; END IF; - INSERT INTO visible + INSERT INTO visible SET itemFk = vItemFk, warehouseFk = vWarehouseFk, quantity = vQuantity diff --git a/db/routines/stock/triggers/inbound_afterDelete.sql b/db/routines/stock/triggers/inbound_afterDelete.sql index b485299b0..451dcc599 100644 --- a/db/routines/stock/triggers/inbound_afterDelete.sql +++ b/db/routines/stock/triggers/inbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE inboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - -OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + -OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/inbound_beforeInsert.sql b/db/routines/stock/triggers/inbound_beforeInsert.sql index 8aabb0682..723cb3222 100644 --- a/db/routines/stock/triggers/inbound_beforeInsert.sql +++ b/db/routines/stock/triggers/inbound_beforeInsert.sql @@ -4,12 +4,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`inbound_beforeInse FOR EACH ROW BEGIN SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_afterDelete.sql b/db/routines/stock/triggers/outbound_afterDelete.sql index dce0aed7a..e7d756871 100644 --- a/db/routines/stock/triggers/outbound_afterDelete.sql +++ b/db/routines/stock/triggers/outbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE outboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_beforeInsert.sql b/db/routines/stock/triggers/outbound_beforeInsert.sql index e41edae43..86546413e 100644 --- a/db/routines/stock/triggers/outbound_beforeInsert.sql +++ b/db/routines/stock/triggers/outbound_beforeInsert.sql @@ -5,12 +5,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_beforeIns BEGIN SET NEW.lack = NEW.quantity; SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - -NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + -NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_requestRecalc.sql b/db/routines/vn/procedures/ticket_requestRecalc.sql index 6636e4c0f..7f1ff3be8 100644 --- a/db/routines/vn/procedures/ticket_requestRecalc.sql +++ b/db/routines/vn/procedures/ticket_requestRecalc.sql @@ -10,6 +10,7 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO ticketRecalc SET ticketFk = vSelf; + -- #4409 Deprecated by MyCDC + -- INSERT INTO ticketRecalc SET ticketFk = vSelf; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterDelete.sql b/db/routines/vn/triggers/buy_afterDelete.sql index 2fcb0852d..5daaefa33 100644 --- a/db/routines/vn/triggers/buy_afterDelete.sql +++ b/db/routines/vn/triggers/buy_afterDelete.sql @@ -3,19 +3,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW trig: BEGIN - DECLARE vValues VARCHAR(255); - IF @isModeInventory OR @isTriggerDisabled THEN LEAVE trig; END IF; - CALL stock.log_add('buy', NULL, OLD.id); - INSERT INTO entryLog SET `action` = 'delete', `changedModel` = 'Buy', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterInsert.sql b/db/routines/vn/triggers/buy_afterInsert.sql index 25682f1bb..b39842d35 100644 --- a/db/routines/vn/triggers/buy_afterInsert.sql +++ b/db/routines/vn/triggers/buy_afterInsert.sql @@ -7,8 +7,6 @@ trig: BEGIN LEAVE trig; END IF; - CALL stock.log_add('buy', NEW.id, NULL); - CALL buy_afterUpsert(NEW.id); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterUpdate.sql b/db/routines/vn/triggers/buy_afterUpdate.sql index 9866f5bb8..fc7ca152d 100644 --- a/db/routines/vn/triggers/buy_afterUpdate.sql +++ b/db/routines/vn/triggers/buy_afterUpdate.sql @@ -12,14 +12,6 @@ trig: BEGIN LEAVE trig; END IF; - IF !(NEW.id <=> OLD.id) - OR !(NEW.entryFk <=> OLD.entryFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) THEN - CALL stock.log_add('buy', NEW.id, OLD.id); - END IF; - CALL buy_afterUpsert(NEW.id); SELECT w.isBuyerToBeEmailed, t.landed diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index 60adc0003..c2d205768 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -3,24 +3,17 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF NOT(NEW.id <=> OLD.id) - OR NOT(NEW.travelFk <=> OLD.travelFk) - OR NOT(NEW.isRaid <=> OLD.isRaid) THEN - CALL stock.log_add('entry', NEW.id, OLD.id); - END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CALL travel_requestRecalc(OLD.travelFk); CALL travel_requestRecalc(NEW.travelFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id FROM buy b WHERE b.entryFk = NEW.id; - + CALL buy_checkItem(); END IF; END$$ diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index fab1c52cd..da74c05ec 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -12,7 +12,6 @@ BEGIN `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - CALL stock.log_add('sale', NULL, OLD.id); CALL ticket_requestRecalc(OLD.ticketFk); SELECT account.myUser_getName() INTO vUserRole; diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index d4c2d60f5..3ce5ce8d9 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -7,7 +7,6 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - CALL stock.log_add('sale', NEW.id, NULL); CALL ticket_requestRecalc(NEW.ticketFk); IF NEW.quantity > 0 THEN diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 0d21f08d7..8500afbe3 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -6,15 +6,6 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - IF !(NEW.id <=> OLD.id) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) - OR !(NEW.isPicked <=> OLD.isPicked) THEN - CALL stock.log_add('sale', NEW.id, OLD.id); - END IF; - IF !(NEW.price <=> OLD.price) OR !(NEW.ticketFk <=> OLD.ticketFk) OR !(NEW.itemFk <=> OLD.itemFk) diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index df939c9d1..fd4b01571 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -3,13 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN - CALL stock.log_add('ticket', NEW.id, OLD.id); - END IF; - IF !(NEW.clientFk <=> OLD.clientFk) OR !(NEW.addressFk <=> OLD.addressFk) OR !(NEW.companyFk <=> OLD.companyFk) THEN @@ -17,7 +10,7 @@ BEGIN END IF; IF NEW.routeFk <> OLD.routeFk THEN - UPDATE expedition + UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index 38cd3ba13..7cfe865f3 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -3,10 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate` AFTER UPDATE ON `travel` FOR EACH ROW BEGIN - CALL stock.log_add('travel', NEW.id, OLD.id); - IF NOT(NEW.shipped <=> OLD.shipped) THEN - UPDATE entry + UPDATE entry SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; END IF; @@ -15,11 +13,11 @@ BEGIN IF (SELECT hasWeightVolumetric FROM agencyMode WHERE id = NEW.agencyModeFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id - FROM entry e + FROM entry e JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk WHERE e.travelFk = NEW.id; - + CALL buy_checkItem(); END IF; END IF; From 92cd61460ea19ceba8ce03728a93a5cfa3e22947 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 8 Apr 2024 09:56:36 +0200 Subject: [PATCH 20/78] feat: refs#6493 Cambios solicitados procedimientos --- .../vn/procedures/available_traslate.sql | 27 ++++++---- db/routines/vn/procedures/balance_create.sql | 52 ++++++++++--------- .../10859-pinkGerbera/00-firstScript.sql | 12 ++--- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 8ef452c6f..d5c6b6da0 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -5,11 +5,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`available_traslate` vWarehouseShipment INT) proc: BEGIN /** - * Calcular la disponibilidad dependiendo del almacen de origen y destino según la fecha + * Calcular la disponibilidad dependiendo del almacen + * de origen y destino según la fecha. * - * @param vWarehouseLanding almacén de llegada. - * @param vDated la fecha para la cual se está calculando la disponibilidad de articulos. - * @param vWarehouseShipment almacén de destino. + * @param vWarehouseLanding almacén de llegada + * @param vDated fecha del calculo para la disponibilidad de articulos + * @param vWarehouseShipment almacén de destino */ DECLARE vDatedFrom DATE; DECLARE vDatedTo DATETIME; @@ -44,7 +45,8 @@ proc: BEGIN AND NOT e.isRaid GROUP BY c.itemFk; - -- Tabla con el ultimo dia de last_buy para cada producto que hace un replace de la anterior + -- Tabla con el ultimo dia de last_buy para cada producto + -- que hace un replace de la anterior. CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange @@ -56,7 +58,8 @@ proc: BEGIN LEFT JOIN tItemRange i ON t.itemFk = i.itemFk WHERE t.warehouseFk = vWarehouseShipment AND NOT e.isRaid - ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, tr.landed); + ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, + tr.landed); CREATE OR REPLACE TEMPORARY TABLE tItemRangeLive (PRIMARY KEY (itemFk)) @@ -67,18 +70,24 @@ proc: BEGIN JOIN itemType it ON it.id = i.typeFk HAVING dated >= vDatedFrom OR dated IS NULL; - -- Calcula el ATP + -- Calcula el ATP. CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk,warehouseFk)) ENGINE = MEMORY - SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity + SELECT i.itemFk, + vWarehouseLanding warehouseFk, + i.shipped dated, + i.quantity FROM itemTicketOut i JOIN tItemRangeLive ir ON ir.itemFK = i.itemFk WHERE i.shipped >= vDatedFrom AND (ir.dated IS NULL OR i.shipped <= ir.dated) AND i.warehouseFk = vWarehouseLanding UNION ALL - SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity + SELECT b.itemFk, + vWarehouseLanding, + t.landed, + b.quantity FROM buy b JOIN entry e ON b.entryFk = e.id JOIN travel t ON t.id = e.travelFk diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index e02a26ca2..0124087cb 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -7,13 +7,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`( IN vInterGroupSalesIncluded BOOLEAN) BEGIN /** - * Crea un balance financiero para una empresa durante un período de tiempo determinado + * Crea un balance financiero para una empresa durante + * un período de tiempo determinado. * * @param vStartingMonth Mes de inicio del período * @param vEndingMonth Mes de finalización del período * @param vCompany Identificador de la empresa * @param vIsConsolidated Indica si se trata de un balance consolidado - * @param vInterGroupSalesIncluded Indica si se incluyen las ventas dentro del grupo + * @param vInterGroupSalesIncluded Indica si se incluyen las ventas del grupo */ DECLARE intGAP INT DEFAULT 7; DECLARE vYears INT DEFAULT 2; @@ -32,19 +33,20 @@ BEGIN SET vOneYearAgo = util.quoteIdentifier(vCurYear-1); SET vTwoYearsAgo = util.quoteIdentifier(vCurYear-2); - -- Solicitamos la tabla tmp.nest, como base para el balance + -- Solicitamos la tabla tmp.nest, como base para el balance. DROP TEMPORARY TABLE IF EXISTS tmp.nest; EXECUTE IMMEDIATE CONCAT( 'CREATE TEMPORARY TABLE tmp.nest SELECT node.id - ,CONCAT( REPEAT(REPEAT(" ",?), COUNT(parent.id) - 1), node.name) AS name - ,node.lft - ,node.rgt - ,COUNT(parent.id) - 1 as depth - ,cast((node.rgt - node.lft - 1) / 2 as DECIMAL) as sons - FROM ', vTable, ' AS node, - ', vTable, ' AS parent + ,CONCAT( REPEAT(REPEAT(" ",?), COUNT(parent.id) - 1), + node.name) name, + node.lft, + node.rgt, + COUNT(parent.id) - 1 depth, + CAST((node.rgt - node.lft - 1) / 2 AS DECIMAL) sons + FROM ', vTable, ' node, + ', vTable, ' parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.id ORDER BY node.lft') @@ -76,7 +78,8 @@ BEGIN END IF; - -- Se calculan las facturas que intervienen, para luego poder servir el desglose desde aqui + -- Se calculan las facturas que intervienen, + -- para luego poder servir el desglose desde aqui. CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail SELECT cr.companyFk receivingId, ci.companyFk issuingId, @@ -90,30 +93,30 @@ BEGIN JOIN tCompanyIssuing ci ON ci.companyFk = r.supplierFk WHERE COALESCE(r.bookEntried, r.booked, r.issued) >= vStartingDate AND r.isBooked - GROUP BY expenseFk, year, month, ci.companyFk, cr.companyFk; + GROUP BY expenseFk, `year`, `month`, ci.companyFk, cr.companyFk; INSERT INTO tmp.balanceDetail( receivingId, issuingId, - year, - month, + `year`, + `month`, expenseFk, amount) SELECT em.companyFk, em.companyFk, - year, - month, + `year`, + `month`, expenseFk, SUM(em.amount) FROM expenseManual em JOIN tCompanyReceiving er ON er.companyFk = em.companyFk - WHERE year >= vStartingYear - AND month BETWEEN vStartingMonth AND vEndingMonth - GROUP BY expenseFk, year, month, em.companyFk; + WHERE `year` >= vStartingYear + AND `month` BETWEEN vStartingMonth AND vEndingMonth + GROUP BY expenseFk, `year`, `month`, em.companyFk; DELETE FROM tmp.balanceDetail - WHERE month < vStartingMonth - OR month > vEndingMonth; + WHERE `month` < vStartingMonth + OR `month` > vEndingMonth; -- Ahora el balance EXECUTE IMMEDIATE CONCAT( @@ -130,8 +133,8 @@ BEGIN JOIN (SELECT id, name FROM expense GROUP BY id) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci - SET b.expenseFk = g.id COLLATE utf8_general_ci - , b.expenseName = g.id COLLATE utf8_general_ci ; + SET b.expenseFk = g.id COLLATE utf8_general_ci, + b.expenseName = g.id COLLATE utf8_general_ci ; -- Rellenamos los valores de primer nivel, los que corresponden a los gastos simples WHILE vYears >= 0 DO @@ -208,8 +211,7 @@ BEGIN SELECT *, CONCAT('',IFNULL(expenseFk,'')) newgasto FROM tmp.balance; - DROP TEMPORARY TABLE IF EXISTS tCompanyReceiving; - DROP TEMPORARY TABLE IF EXISTS tCompanyIssuing; + DROP TEMPORARY TABLE IF EXISTS tCompanyReceiving, tCompanyIssuing; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10859-pinkGerbera/00-firstScript.sql b/db/versions/10859-pinkGerbera/00-firstScript.sql index 8fcadf605..a4683d93a 100644 --- a/db/versions/10859-pinkGerbera/00-firstScript.sql +++ b/db/versions/10859-pinkGerbera/00-firstScript.sql @@ -2,14 +2,8 @@ CREATE OR REPLACE PROCEDURE `vn`.`balance_create`() BEGIN END; CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByEntry`() BEGIN END; CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByBuy`() BEGIN END; -GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`; -GRANT EXECUTE ON PROCEDURE vn.balance_create TO `hrBoss`; +GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`, `hrBoss`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `claimManager`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `employee`; +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`, `claimManager`, `employee`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `buyer`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `entryEditor`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `claimManager`; -GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `employee`; \ No newline at end of file +GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `buyer`, `entryEditor`, `claimManager`, `employee`; \ No newline at end of file From 957b0c71ca8922f5493574c854c518e85f9bff55 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 8 Apr 2024 10:06:33 +0200 Subject: [PATCH 21/78] refs #6574 feat: add order --- db/routines/vn/procedures/item_getBalance.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 95596d3bc..d84605176 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -173,7 +173,8 @@ BEGIN lineFk, isPicked, clientType, - claimFk + claimFk, + `order` FROM tItemDiary LEFT JOIN alertLevel a ON a.id = tItemDiary.alertLevel; @@ -197,7 +198,8 @@ BEGIN 0 lineFk, 0 isPicked, 0 clientType, - 0 claimFk + 0 claimFk, + `order` UNION ALL SELECT shipped, alertlevel, @@ -213,7 +215,8 @@ BEGIN lineFk, isPicked, clientType, - claimFk + claimFk, + `order` FROM tItemDiary WHERE shipped >= vDate; END IF; From 42b033dde295fbba1e8196be4e3f218f864293b1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 8 Apr 2024 11:35:10 +0200 Subject: [PATCH 22/78] refs #6574 feat: add order --- db/routines/vn/procedures/item_getBalance.sql | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index d84605176..e7a3641e0 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -156,27 +156,27 @@ BEGIN SET @shipped := ''; SELECT DATE(@shipped:= shipped) shipped, - alertLevel, - stateName, - origin, - reference, - clientFk, - name, - `in` invalue, - `out`, - @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0) balance, + t.alertLevel, + t.stateName, + t.origin, + t.reference, + t.clientFk, + t.name, + t.`in` invalue, + t.`out`, + @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, @currentLineFk := IF (@shipped < util.VN_CURDATE() OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.`code` >= 'ON_PREPARATION')), - lineFk, + t.lineFk, @currentLineFk) lastPreparedLineFk, - isTicket, - lineFk, - isPicked, - clientType, - claimFk, - `order` - FROM tItemDiary - LEFT JOIN alertLevel a ON a.id = tItemDiary.alertLevel; + t.isTicket, + t.lineFk, + t.isPicked, + t.clientType, + t.claimFk, + t.`order` + FROM tItemDiary t + LEFT JOIN alertLevel a ON a.id = t.alertLevel; ELSE SELECT SUM(`in`) - SUM(`out`) INTO @a @@ -199,7 +199,7 @@ BEGIN 0 isPicked, 0 clientType, 0 claimFk, - `order` + NULL `order` UNION ALL SELECT shipped, alertlevel, From d3df3e3376a23db00e9d5313c93dfda33f133242 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 8 Apr 2024 12:57:01 +0200 Subject: [PATCH 23/78] feat: refs#6493 Cambios solicitados procedimientos --- .../vn/procedures/available_traslate.sql | 28 +++++++++---------- db/routines/vn/procedures/balance_create.sql | 25 +++++++++-------- .../10859-pinkGerbera/00-firstScript.sql | 2 -- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index d5c6b6da0..615707da2 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -8,9 +8,9 @@ proc: BEGIN * Calcular la disponibilidad dependiendo del almacen * de origen y destino según la fecha. * - * @param vWarehouseLanding almacén de llegada - * @param vDated fecha del calculo para la disponibilidad de articulos - * @param vWarehouseShipment almacén de destino + * @param vWarehouseLanding Almacén de llegada + * @param vDated Fecha del calculo para la disponibilidad de articulos + * @param vWarehouseShipment Almacén de destino */ DECLARE vDatedFrom DATE; DECLARE vDatedTo DATETIME; @@ -23,14 +23,14 @@ proc: BEGIN CALL item_getStock (vWarehouseLanding, vDated, NULL); - -- Calcula algunos parámetros necesarios + -- Calcula algunos parámetros necesarios. SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); SELECT FechaInventario INTO vDatedInventory FROM tblContadores; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; - -- Calcula el ultimo dia de vida para cada producto + -- Calcula el ultimo dia de vida para cada producto. CREATE OR REPLACE TEMPORARY TABLE tItemRange (PRIMARY KEY (itemFk)) ENGINE = MEMORY @@ -89,15 +89,15 @@ proc: BEGIN t.landed, b.quantity FROM buy b - JOIN entry e ON b.entryFk = e.id - JOIN travel t ON t.id = e.travelFk - JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk - WHERE NOT e.isExcludedFromAvailable - AND b.quantity <> 0 - AND NOT e.isRaid - AND t.warehouseInFk = vWarehouseLanding - AND t.landed >= vDatedFrom - AND (ir.dated IS NULL OR t.landed <= ir.dated) + JOIN entry e ON b.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk + WHERE NOT e.isExcludedFromAvailable + AND b.quantity <> 0 + AND NOT e.isRaid + AND t.warehouseInFk = vWarehouseLanding + AND t.landed >= vDatedFrom + AND (ir.dated IS NULL OR t.landed <= ir.dated) UNION ALL SELECT i.itemFk, vWarehouseLanding, i.shipped, i.quantity FROM itemEntryOut i diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 0124087cb..23c7b6f02 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -130,23 +130,26 @@ BEGIN -- Añadimos los gastos, para facilitar el formulario UPDATE tmp.balance b JOIN balanceNestTree bnt on bnt.id = b.id - JOIN (SELECT id, name + JOIN ( + SELECT id, name FROM expense - GROUP BY id) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci + GROUP BY id + ) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci SET b.expenseFk = g.id COLLATE utf8_general_ci, b.expenseName = g.id COLLATE utf8_general_ci ; - -- Rellenamos los valores de primer nivel, los que corresponden a los gastos simples + -- Rellenamos los valores de primer nivel, los que corresponden + -- a los gastos simples. WHILE vYears >= 0 DO SET vQuery = CONCAT( 'UPDATE tmp.balance b - JOIN - (SELECT expenseFk, SUM(amount) amount + JOIN ( + SELECT expenseFk, SUM(amount) amount FROM tmp.balanceDetail WHERE year = ? GROUP BY expenseFk - ) sub on sub.expenseFk = b.expenseFk COLLATE utf8_general_ci - SET ', util.quoteIdentifier(vCurYear - vYears), ' = - amount'); + ) sub on sub.expenseFk = b.expenseFk COLLATE utf8_general_ci + SET ', util.quoteIdentifier(vCurYear - vYears), ' = - amount'); EXECUTE IMMEDIATE vQuery USING vCurYear - vYears; @@ -154,7 +157,7 @@ BEGIN SET vYears = vYears - 1; END WHILE; - -- Añadimos las ventas + -- Añadimos las ventas. EXECUTE IMMEDIATE CONCAT( 'UPDATE tmp.balance b JOIN ( @@ -164,7 +167,7 @@ BEGIN c.Gasto FROM bs.ventas_contables c JOIN tCompanyReceiving cr ON cr.companyFk = c.empresa_id - WHERE month BETWEEN ? AND ? + WHERE month BETWEEN ? AND ? GROUP BY c.Gasto ) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci SET b.', vTwoYearsAgo, '= IFNULL(b.', vTwoYearsAgo, ', 0) + sub.y2, @@ -176,7 +179,7 @@ BEGIN vStartingMonth, vEndingMonth; - -- Ventas intra grupo + -- Ventas intra grupo. IF NOT vInterGroupSalesIncluded THEN SELECT lft, rgt INTO @grupoLft, @grupoRgt @@ -189,7 +192,7 @@ BEGIN END IF; - -- Rellenamos el valor de los padres con la suma de los hijos + -- Rellenamos el valor de los padres con la suma de los hijos. CREATE OR REPLACE TEMPORARY TABLE tmp.balance_aux SELECT * FROM tmp.balance; diff --git a/db/versions/10859-pinkGerbera/00-firstScript.sql b/db/versions/10859-pinkGerbera/00-firstScript.sql index a4683d93a..1aed01319 100644 --- a/db/versions/10859-pinkGerbera/00-firstScript.sql +++ b/db/versions/10859-pinkGerbera/00-firstScript.sql @@ -3,7 +3,5 @@ CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByEntry`() BEGIN END; CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByBuy`() BEGIN END; GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`, `hrBoss`; - GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`, `claimManager`, `employee`; - GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByBuy TO `buyer`, `entryEditor`, `claimManager`, `employee`; \ No newline at end of file From 2f7f2374224f58d3c1e87b1f256abf63c749ea7f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 8 Apr 2024 13:28:38 +0200 Subject: [PATCH 24/78] refs #6574 feat: add order --- db/routines/vn/procedures/item_getBalance.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index e7a3641e0..11af7e570 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -155,7 +155,7 @@ BEGIN SET @currentLineFk := 0; SET @shipped := ''; - SELECT DATE(@shipped:= shipped) shipped, + SELECT DATE(@shipped:= t.shipped) shipped, t.alertLevel, t.stateName, t.origin, @@ -166,7 +166,7 @@ BEGIN t.`out`, @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, @currentLineFk := IF (@shipped < util.VN_CURDATE() - OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.`code` >= 'ON_PREPARATION')), + OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')), t.lineFk, @currentLineFk) lastPreparedLineFk, t.isTicket, From 1534402640c4dc4dade02fdbc2d4a0b0449e3881 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 8 Apr 2024 13:28:56 +0200 Subject: [PATCH 25/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/available_traslate.sql | 12 ++++++------ db/routines/vn/procedures/balance_create.sql | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 615707da2..d45c913bc 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -75,9 +75,9 @@ proc: BEGIN (INDEX (itemFk,warehouseFk)) ENGINE = MEMORY SELECT i.itemFk, - vWarehouseLanding warehouseFk, - i.shipped dated, - i.quantity + vWarehouseLanding warehouseFk, + i.shipped dated, + i.quantity FROM itemTicketOut i JOIN tItemRangeLive ir ON ir.itemFK = i.itemFk WHERE i.shipped >= vDatedFrom @@ -85,9 +85,9 @@ proc: BEGIN AND i.warehouseFk = vWarehouseLanding UNION ALL SELECT b.itemFk, - vWarehouseLanding, - t.landed, - b.quantity + vWarehouseLanding, + t.landed, + b.quantity FROM buy b JOIN entry e ON b.entryFk = e.id JOIN travel t ON t.id = e.travelFk diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 23c7b6f02..8a1b77c95 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -206,7 +206,8 @@ BEGIN SUM(b2.', vTwoYearsAgo,') twoYearsAgo FROM tmp.nest b1 JOIN tmp.balance_aux b2 on b2.lft BETWEEN b1.lft and b1.rgt - GROUP BY b1.id)sub ON sub.id = b.id + GROUP BY b1.id + )sub ON sub.id = b.id SET b.', vYear, ' = thisYear, b.', vOneYearAgo, ' = oneYearAgo, b.', vTwoYearsAgo, ' = twoYearsAgo'); From 2d4524a34c2d9c2f57d177d1782110d823d4f088 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 10 Apr 2024 09:00:41 +0200 Subject: [PATCH 26/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/available_traslate.sql | 2 +- db/routines/vn/procedures/balance_create.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index d45c913bc..9934c1c44 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -26,7 +26,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios. SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT inventoried INTO vDatedInventory FROM config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 8a1b77c95..40a8b020c 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -136,7 +136,7 @@ BEGIN GROUP BY id ) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci SET b.expenseFk = g.id COLLATE utf8_general_ci, - b.expenseName = g.id COLLATE utf8_general_ci ; + b.expenseName = g.name COLLATE utf8_general_ci ; -- Rellenamos los valores de primer nivel, los que corresponden -- a los gastos simples. From c2a2a86f355aa30ffb225cdf9d311bacfcdc289b Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 10 Apr 2024 09:42:55 +0200 Subject: [PATCH 27/78] feat: refs #6777 ultima comprobacion --- .../bs/procedures/ventas_contables_add.sql | 16 +++--- .../ventas_contables_por_cliente.sql | 14 +++--- db/routines/vn2008/views/Rutas.sql | 19 ------- db/routines/vn2008/views/state.sql | 13 ----- db/routines/vn2008/views/tag.sql | 10 ---- .../vn2008/views/tarifa_componentes.sql | 10 ---- .../views/tarifa_componentes_series.sql | 7 --- db/routines/vn2008/views/tblContadores.sql | 39 --------------- db/routines/vn2008/views/thermograph.sql | 6 --- .../vn2008/views/ticket_observation.sql | 8 --- db/routines/vn2008/views/tickets_gestdoc.sql | 6 --- .../10921-bronzeAralia/00-firstScript.sql | 49 ------------------- 12 files changed, 15 insertions(+), 182 deletions(-) delete mode 100644 db/routines/vn2008/views/Rutas.sql delete mode 100644 db/routines/vn2008/views/state.sql delete mode 100644 db/routines/vn2008/views/tag.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql delete mode 100644 db/routines/vn2008/views/tblContadores.sql delete mode 100644 db/routines/vn2008/views/thermograph.sql delete mode 100644 db/routines/vn2008/views/ticket_observation.sql delete mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql delete mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index abb4be25d..ad4e80a06 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -21,9 +21,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.`ref` = t.Factura + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.`ref` = t.refFk WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , a.expenseFk + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,8 +54,8 @@ BEGIN ) * 100000 + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + 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 @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26ba670b1..ed3773cf7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,13 +10,13 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + (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; - + AND month(io.issued) = vMonth; + SELECT vYear Año, vMonth Mes, t.clientFk Id_Cliente, @@ -40,7 +40,7 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != 188 GROUP BY t.clientFk, grupo,t.companyFk; - + DROP TEMPORARY TABLE tmp.ticket_list; END$$ diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql deleted file mode 100644 index 78b3bb471..000000000 --- a/db/routines/vn2008/views/Rutas.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas` -AS SELECT `r`.`id` AS `Id_Ruta`, - `r`.`workerFk` AS `Id_Trabajador`, - `r`.`created` AS `Fecha`, - `r`.`vehicleFk` AS `Id_Vehiculo`, - `r`.`agencyModeFk` AS `Id_Agencia`, - `r`.`time` AS `Hora`, - `r`.`isOk` AS `ok`, - `r`.`kmStart` AS `km_start`, - `r`.`kmEnd` AS `km_end`, - `r`.`started` AS `date_start`, - `r`.`finished` AS `date_end`, - `r`.`gestdocFk` AS `gestdoc_id`, - `r`.`cost` AS `cost`, - `r`.`m3` AS `m3`, - `r`.`description` AS `description` -FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql deleted file mode 100644 index 63f6589af..000000000 --- a/db/routines/vn2008/views/state.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`state` -AS SELECT `s`.`id` AS `id`, - `s`.`name` AS `name`, - `s`.`order` AS `order`, - `s`.`alertLevel` AS `alert_level`, - `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, - `s`.`nextStateFk` AS `nextStateFk`, - `s`.`isPreviousPreparable` AS `isPreviousPreparable`, - `s`.`isPicked` AS `isPicked` -FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql deleted file mode 100644 index 25b3ab82e..000000000 --- a/db/routines/vn2008/views/tag.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tag` -AS SELECT `t`.`id` AS `id`, - `t`.`name` AS `name`, - `t`.`isFree` AS `isFree`, - `t`.`isQuantitatif` AS `isQuantitatif`, - `t`.`sourceTable` AS `sourceTable`, - `t`.`unit` AS `unit` -FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql deleted file mode 100644 index bec53abd9..000000000 --- a/db/routines/vn2008/views/tarifa_componentes.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes` -AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, - `tarifa_componentes`.`Componente` AS `Componente`, - `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, - `tarifa_componentes`.`tax` AS `tax`, - `tarifa_componentes`.`is_renewable` AS `is_renewable` -FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql deleted file mode 100644 index a1d188709..000000000 --- a/db/routines/vn2008/views/tarifa_componentes_series.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes_series` -AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes_series`.`Serie` AS `Serie`, - `tarifa_componentes_series`.`base` AS `base` -FROM `bi`.`tarifa_componentes_series` diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql deleted file mode 100644 index 129d3ce8b..000000000 --- a/db/routines/vn2008/views/tblContadores.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tblContadores` -AS SELECT `c`.`id` AS `id`, - `c`.`ochoa` AS `ochoa`, - `c`.`invoiceOutFk` AS `nfactura`, - `c`.`inventoried` AS `FechaInventario`, - `c`.`itemLog` AS `HistoricoArticulo`, - `c`.`weekGoal` AS `week_goal`, - `c`.`photosPath` AS `Rutafotos`, - `c`.`cashBoxNumber` AS `numCaja`, - `c`.`redCode` AS `CodigoRojo`, - `c`.`TabletTime` AS `Tablet_Hora`, - `c`.`t0` AS `t0`, - `c`.`t1` AS `t1`, - `c`.`t2` AS `t2`, - `c`.`t3` AS `t3`, - `c`.`cc` AS `cc`, - `c`.`palet` AS `palet`, - `c`.`campaign` AS `campaign`, - `c`.`campaignLife` AS `campaign_life`, - `c`.`truckDays` AS `truck_days`, - `c`.`transportCharges` AS `tasa_transporte`, - `c`.`escanerPath` AS `escaner_path`, - `c`.`printedTurn` AS `turnoimpreso`, - `c`.`truckLength` AS `truck_length`, - `c`.`fuelConsumption` AS `fuel_consumption`, - `c`.`petrol` AS `petrol`, - `c`.`maintenance` AS `maintenance`, - `c`.`hourPrice` AS `hour_price`, - `c`.`meterPrice` AS `meter_price`, - `c`.`kmPrice` AS `km_price`, - `c`.`routeOption` AS `route_option`, - `c`.`dbproduccion` AS `dbproduccion`, - `c`.`mdbServer` AS `mdbServer`, - `c`.`fakeEmail` AS `fakeEmail`, - `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, - `c`.`ASIEN` AS `ASIEN` -FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql deleted file mode 100644 index f51b83d24..000000000 --- a/db/routines/vn2008/views/thermograph.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`thermograph` -AS SELECT `t`.`id` AS `thermograph_id`, - `t`.`model` AS `model` -FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql deleted file mode 100644 index deb85e4b6..000000000 --- a/db/routines/vn2008/views/ticket_observation.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`ticket_observation` -AS SELECT `to`.`id` AS `ticket_observation_id`, - `to`.`ticketFk` AS `Id_Ticket`, - `to`.`observationTypeFk` AS `observation_type_id`, - `to`.`description` AS `text` -FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql deleted file mode 100644 index a8682db57..000000000 --- a/db/routines/vn2008/views/tickets_gestdoc.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tickets_gestdoc` -AS SELECT `td`.`ticketFk` AS `Id_Ticket`, - `td`.`dmsFk` AS `gestdoc_id` -FROM `vn`.`ticketDms` `td` diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql deleted file mode 100644 index 55aa03dca..000000000 --- a/db/versions/10921-bronzeAralia/00-firstScript.sql +++ /dev/null @@ -1,49 +0,0 @@ --- Para evitar el error al hacer myt run -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Clientes` -AS SELECT `c`.`id` AS `id_cliente`, - `c`.`name` AS `cliente`, - `c`.`fi` AS `if`, - `c`.`socialName` AS `razonSocial`, - `c`.`contact` AS `contacto`, - `c`.`street` AS `domicilio`, - `c`.`city` AS `poblacion`, - `c`.`postcode` AS `codPostal`, - `c`.`phone` AS `telefono`, - `c`.`mobile` AS `movil`, - `c`.`isRelevant` AS `real`, - `c`.`email` AS `e-mail`, - `c`.`iban` AS `iban`, - `c`.`dueDay` AS `vencimiento`, - `c`.`accountingAccount` AS `Cuenta`, - `c`.`isEqualizated` AS `RE`, - `c`.`provinceFk` AS `province_id`, - `c`.`hasToInvoice` AS `invoice`, - `c`.`credit` AS `credito`, - `c`.`countryFk` AS `Id_Pais`, - `c`.`isActive` AS `activo`, - `c`.`gestdocFk` AS `gestdoc_id`, - `c`.`quality` AS `calidad`, - `c`.`payMethodFk` AS `pay_met_id`, - `c`.`created` AS `created`, - `c`.`isToBeMailed` AS `mail`, - `c`.`contactChannelFk` AS `chanel_id`, - `c`.`hasSepaVnl` AS `sepaVnl`, - `c`.`hasCoreVnl` AS `coreVnl`, - `c`.`hasCoreVnh` AS `coreVnh`, - `c`.`hasLcr` AS `hasLcr`, - `c`.`defaultAddressFk` AS `default_address`, - `c`.`riskCalculated` AS `risk_calculated`, - `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, - `c`.`isTaxDataChecked` AS `contabilizado`, - `c`.`isFreezed` AS `congelado`, - `c`.`creditInsurance` AS `creditInsurance`, - `c`.`isCreatedAsServed` AS `isCreatedAsServed`, - `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`; \ No newline at end of file From 67172676139a69aa27d52566856590d4d9734b3f Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Wed, 10 Apr 2024 11:23:33 +0200 Subject: [PATCH 28/78] refs ~6921 feat:addNoteFromDelivery --- .../vn/procedures/addNoteFromDelivery.sql | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 61295b7db..37bb198ad 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -1,13 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(vTicketFk INT, vDescription TEXT, vCode VARCHAR(45)) BEGIN - - DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ - INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) - VALUES (idTicket,observationTypeFk,nota) - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); + /** + * Inserta observaciones para los tickets + * + * @param vTicketFk Identificador del ticket + * @param vDescription Texto de la nota a insertar + * param vCode Identificador del tipo de nota + */ + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vTicketFk, id, vDescription + FROM vn.observationType + WHERE code = vCode + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description, VALUES(description),' '); END$$ DELIMITER ; From 0956dbc7b1c2f280ac745d50bc5ac841e8cb9061 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 11:32:45 +0200 Subject: [PATCH 29/78] refs #6921 feat: addFromDelivery --- db/versions/10987-tealMonstera/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10987-tealMonstera/00-firstScript.sql diff --git a/db/versions/10987-tealMonstera/00-firstScript.sql b/db/versions/10987-tealMonstera/00-firstScript.sql new file mode 100644 index 000000000..e78d54fd4 --- /dev/null +++ b/db/versions/10987-tealMonstera/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +USE vn; +INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff') \ No newline at end of file From b46102653b24bba10c087bcd4819f9b6284e4c8c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 11:35:28 +0200 Subject: [PATCH 30/78] refs #6921 feat: addFromDelivery --- db/routines/vn/procedures/addNoteFromDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 37bb198ad..7431d4f49 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -7,7 +7,7 @@ BEGIN * * @param vTicketFk Identificador del ticket * @param vDescription Texto de la nota a insertar - * param vCode Identificador del tipo de nota + * @param vCode Identificador del tipo de nota */ INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) From 9c373d9ef3d9fa83ee5cd2fb306665c5f9575a21 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 12:02:25 +0200 Subject: [PATCH 31/78] refs #6921 feat: getTicketsObservations --- modules/route/back/methods/route/getTickets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 59ba389ed..6f7162178 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -44,13 +44,13 @@ module.exports = Self => { st.name ticketStateName, wh.name warehouseName, tob.description ticketObservation, + tob2.description ticketObservationDropOff, a.street, a.postalCode, a.city, am.name agencyModeName, u.nickname userNickname, vn.ticketTotalVolume(t.id) volume, - tob.description, GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, c.phone clientPhone, c.mobile clientMobile, @@ -72,6 +72,9 @@ module.exports = Self => { LEFT JOIN observationType ot ON ot.code = 'delivery' LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk LEFT JOIN account.user u ON u.id = r.workerFk From d24de61213e68fea6df21da0d8e7ae7c970a62c3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Apr 2024 08:29:39 +0200 Subject: [PATCH 32/78] refs #6921 feat: addFromDelivery --- modules/route/back/methods/route/getTickets.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 6f7162178..2393018cf 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -43,8 +43,9 @@ module.exports = Self => { st.code ticketStateCode, st.name ticketStateName, wh.name warehouseName, - tob.description ticketObservation, - tob2.description ticketObservationDropOff, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id, a.street, a.postalCode, a.city, From 187c918a21e0c7c2add31df5aa52195ea94788b6 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 17 Apr 2024 07:33:08 +0200 Subject: [PATCH 33/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/balance_create.sql | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 40a8b020c..a3175c514 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -69,9 +69,9 @@ BEGIN SELECT id companyFk FROM supplier p; - IF vInterGroupSalesIncluded = FALSE THEN + IF NOT vInterGroupSalesIncluded THEN - DELETE ci.* + DELETE ci. FROM tCompanyIssuing ci JOIN company e on e.id = ci.companyFk WHERE e.companyGroupFk = vConsolidatedGroup; @@ -130,13 +130,9 @@ BEGIN -- Añadimos los gastos, para facilitar el formulario UPDATE tmp.balance b JOIN balanceNestTree bnt on bnt.id = b.id - JOIN ( - SELECT id, name - FROM expense - GROUP BY id - ) g ON g.id = bnt.expenseFk COLLATE utf8_general_ci - SET b.expenseFk = g.id COLLATE utf8_general_ci, - b.expenseName = g.name COLLATE utf8_general_ci ; + JOIN expense e ON e.id = bnt.expenseFk COLLATE utf8_general_ci + SET b.expenseFk = e.id COLLATE utf8_general_ci, + b.expenseName = e.name COLLATE utf8_general_ci ; -- Rellenamos los valores de primer nivel, los que corresponden -- a los gastos simples. @@ -182,13 +178,13 @@ BEGIN -- Ventas intra grupo. IF NOT vInterGroupSalesIncluded THEN - SELECT lft, rgt INTO @grupoLft, @grupoRgt + SELECT lft, rgt INTO @groupLft, @groupRgt FROM tmp.balance b WHERE TRIM(b.`name`) = 'Grupo'; DELETE FROM tmp.balance - WHERE lft BETWEEN @grupoLft AND @grupoRgt; + WHERE lft BETWEEN @groupLft AND @groupRgt; END IF; From 3950d603874c8edcc825f75d6da36ecec7158f15 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 17 Apr 2024 07:37:58 +0200 Subject: [PATCH 34/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/balance_create.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index a3175c514..1b3b2162c 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -71,7 +71,7 @@ BEGIN IF NOT vInterGroupSalesIncluded THEN - DELETE ci. + DELETE ci FROM tCompanyIssuing ci JOIN company e on e.id = ci.companyFk WHERE e.companyGroupFk = vConsolidatedGroup; From ae326e6e2edaa7f6db264266e69b9878173e6c03 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Apr 2024 13:21:27 +0200 Subject: [PATCH 35/78] feat(binlog): refs #4409 Old recalc code removed Queues: orderTotal, ticketTotal and travelEntries --- db/dump/fixtures.before.sql | 28 +++++++--- db/routines/hedera/events/order_doRecalc.sql | 8 --- .../hedera/procedures/order_doRecalc.sql | 53 ------------------- .../hedera/procedures/order_requestRecalc.sql | 16 ------ .../hedera/triggers/orderRow_afterDelete.sql | 8 --- .../hedera/triggers/orderRow_afterInsert.sql | 8 --- .../hedera/triggers/orderRow_afterUpdate.sql | 9 ---- .../hedera/triggers/order_afterUpdate.sql | 6 --- db/routines/vn/events/ticket_doRecalc.sql | 8 --- db/routines/vn/events/travel_doRecalc.sql | 8 --- db/routines/vn/procedures/ticket_doRecalc.sql | 53 ------------------- .../vn/procedures/ticket_recalcByScope.sql | 40 ++++++++++++++ .../vn/procedures/ticket_requestRecalc.sql | 16 ------ db/routines/vn/procedures/travel_doRecalc.sql | 34 ------------ db/routines/vn/procedures/travel_recalc.sql | 17 ++++++ .../vn/procedures/travel_requestRecalc.sql | 15 ------ .../vn/triggers/address_afterUpdate.sql | 26 ++++----- .../vn/triggers/client_afterUpdate.sql | 15 ++---- db/routines/vn/triggers/entry_afterDelete.sql | 2 - db/routines/vn/triggers/entry_afterInsert.sql | 8 --- db/routines/vn/triggers/entry_afterUpdate.sql | 5 -- db/routines/vn/triggers/sale_afterDelete.sql | 2 - db/routines/vn/triggers/sale_afterInsert.sql | 3 -- db/routines/vn/triggers/sale_afterUpdate.sql | 9 ---- .../vn/triggers/ticketService_afterDelete.sql | 3 -- .../vn/triggers/ticketService_afterInsert.sql | 10 ---- .../vn/triggers/ticketService_afterUpdate.sql | 13 ----- .../vn/triggers/ticket_afterUpdate.sql | 7 --- .../10996-pinkPhormium/00-dropOrderRecalc.sql | 1 + .../01-dropTicketRecalc.sql | 1 + .../02-dropTravelRecalc.sql | 1 + 31 files changed, 97 insertions(+), 336 deletions(-) delete mode 100644 db/routines/hedera/events/order_doRecalc.sql delete mode 100644 db/routines/hedera/procedures/order_doRecalc.sql delete mode 100644 db/routines/hedera/procedures/order_requestRecalc.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterDelete.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterInsert.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterUpdate.sql delete mode 100644 db/routines/vn/events/ticket_doRecalc.sql delete mode 100644 db/routines/vn/events/travel_doRecalc.sql delete mode 100644 db/routines/vn/procedures/ticket_doRecalc.sql create mode 100644 db/routines/vn/procedures/ticket_recalcByScope.sql delete mode 100644 db/routines/vn/procedures/ticket_requestRecalc.sql delete mode 100644 db/routines/vn/procedures/travel_doRecalc.sql create mode 100644 db/routines/vn/procedures/travel_recalc.sql delete mode 100644 db/routines/vn/procedures/travel_requestRecalc.sql delete mode 100644 db/routines/vn/triggers/entry_afterInsert.sql delete mode 100644 db/routines/vn/triggers/ticketService_afterInsert.sql delete mode 100644 db/routines/vn/triggers/ticketService_afterUpdate.sql create mode 100644 db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql create mode 100644 db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql create mode 100644 db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c9832545f..9b14cf1fd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2614,13 +2614,29 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); -INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT t.id - FROM vn.ticket t - LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id - WHERE tr.ticketFk IS NULL; +DELIMITER $$ +CREATE PROCEDURE `tmp`.`ticket_recalc`() +BEGIN + DECLARE vDone BOOL; + DECLARE vTicketFk INT; -CALL `vn`.`ticket_doRecalc`(); + DECLARE cCur CURSOR FOR SELECT id FROM vn.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk; + IF vDone THEN LEAVE myLoop; END IF; + CALL vn.ticket_recalc(vTicketFk, NULL); + END LOOP; + CLOSE cCur; +END$$ +DELIMITER ; + +CALL tmp.ticket_recalc; +DROP PROCEDURE tmp.ticket_recalc; UPDATE `vn`.`ticket` SET refFk = 'T1111111' diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql deleted file mode 100644 index d355e1a55..000000000 --- a/db/routines/hedera/events/order_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `hedera`.`order_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2019-08-29 14:18:04.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL order_doRecalc$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_doRecalc.sql b/db/routines/hedera/procedures/order_doRecalc.sql deleted file mode 100644 index 4c0ee0499..000000000 --- a/db/routines/hedera/procedures/order_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_doRecalc`() -proc: BEGIN -/** - * Recalculates modified orders. - */ - DECLARE vDone BOOL; - DECLARE vOrderFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT orderFk FROM tOrder; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('hedera.order_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('hedera.order_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tOrder; - CREATE TEMPORARY TABLE tOrder - ENGINE = MEMORY - SELECT id, orderFk FROM orderRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vOrderFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL order_recalc(vOrderFk); - END LOOP; - - CLOSE cCur; - - DELETE o FROM orderRecalc o JOIN tOrder t ON t.id = o.id; - - DROP TEMPORARY TABLE tOrder; - - DO RELEASE_LOCK('hedera.order_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql deleted file mode 100644 index aae4a0179..000000000 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the order total. - * - * @param vSelf The order identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - -- #4409 Deprecated by MyCDC - -- INSERT INTO orderRecalc SET orderFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterDelete.sql b/db/routines/hedera/triggers/orderRow_afterDelete.sql deleted file mode 100644 index e22f786c1..000000000 --- a/db/routines/hedera/triggers/orderRow_afterDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterDelete` - AFTER DELETE ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(OLD.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql deleted file mode 100644 index c95e0bbdc..000000000 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert` - AFTER INSERT ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterUpdate.sql b/db/routines/hedera/triggers/orderRow_afterUpdate.sql deleted file mode 100644 index bce81a8e4..000000000 --- a/db/routines/hedera/triggers/orderRow_afterUpdate.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterUpdate` - AFTER UPDATE ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(OLD.orderFk); - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql index da82d242c..25f51b3f0 100644 --- a/db/routines/hedera/triggers/order_afterUpdate.sql +++ b/db/routines/hedera/triggers/order_afterUpdate.sql @@ -3,12 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate AFTER UPDATE ON `order` FOR EACH ROW BEGIN - IF !(OLD.address_id <=> NEW.address_id) - OR !(OLD.company_id <=> NEW.company_id) - OR !(OLD.customer_id <=> NEW.customer_id) THEN - CALL order_requestRecalc(NEW.id); - END IF; - IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN -- Fallo que se actualiza no se sabe como tickets en este cliente CALL vn.mail_insert( diff --git a/db/routines/vn/events/ticket_doRecalc.sql b/db/routines/vn/events/ticket_doRecalc.sql deleted file mode 100644 index 9209c5715..000000000 --- a/db/routines/vn/events/ticket_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`ticket_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2022-01-28 09:29:18.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL ticket_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/events/travel_doRecalc.sql b/db/routines/vn/events/travel_doRecalc.sql deleted file mode 100644 index a08ecc068..000000000 --- a/db/routines/vn/events/travel_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_doRecalc` - ON SCHEDULE EVERY 15 SECOND - STARTS '2019-05-17 10:52:29.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL travel_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_doRecalc.sql b/db/routines/vn/procedures/ticket_doRecalc.sql deleted file mode 100644 index 1dd2a05cb..000000000 --- a/db/routines/vn/procedures/ticket_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRecalc`() -proc: BEGIN -/** - * Recalculates modified ticket. - */ - DECLARE vDone BOOL; - DECLARE vTicketFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT ticketFk FROM tTicket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('vn.ticket_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tTicket; - CREATE TEMPORARY TABLE tTicket - ENGINE = MEMORY - SELECT id, ticketFk FROM ticketRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vTicketFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL ticket_recalc(vTicketFk, NULL); - END LOOP; - - CLOSE cCur; - - DELETE tr FROM ticketRecalc tr JOIN tTicket t ON tr.id = t.id; - - DROP TEMPORARY TABLE tTicket; - - DO RELEASE_LOCK('vn.ticket_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql new file mode 100644 index 000000000..e20244648 --- /dev/null +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -0,0 +1,40 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcByScope`( + vScope VARCHAR(255), + vId INT +) +BEGIN +/** + * Recalculates tickets in an scope. + * + * @param vScope The scope name + * @param vId The scope id + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE cCur CURSOR FOR + SELECT id FROM ticket + WHERE refFk IS NULL + AND ((vScope = 'client' AND clientFk = vId) + OR (vScope = 'address' AND addressFk = vId)); + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL ticket_recalc(vTicketFk, NULL); + END LOOP; + + CLOSE cCur; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_requestRecalc.sql b/db/routines/vn/procedures/ticket_requestRecalc.sql deleted file mode 100644 index 7f1ff3be8..000000000 --- a/db/routines/vn/procedures/ticket_requestRecalc.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the ticket total. - * - * @param vSelf The ticket identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - -- #4409 Deprecated by MyCDC - -- INSERT INTO ticketRecalc SET ticketFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_doRecalc.sql b/db/routines/vn/procedures/travel_doRecalc.sql deleted file mode 100644 index 5d877174c..000000000 --- a/db/routines/vn/procedures/travel_doRecalc.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_doRecalc`() -proc: BEGIN -/** -* Recounts the number of entries of changed travels. -*/ - DECLARE vTravelFk INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - END; - - IF !GET_LOCK('vn.travel_doRecalc', 0) THEN - LEAVE proc; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tTravel - ENGINE = MEMORY - SELECT travelFk FROM travelRecalc; - - UPDATE travel t - JOIN tTravel tt ON tt.travelFk = t.id - SET t.totalEntries = ( - SELECT COUNT(e.id) - FROM entry e - WHERE e.travelFk = t.id - ); - - DELETE tr FROM travelRecalc tr JOIN tTravel t ON tr.travelFk = t.travelFk; - DROP TEMPORARY TABLE tTravel; - DO RELEASE_LOCK('vn.travel_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_recalc.sql b/db/routines/vn/procedures/travel_recalc.sql new file mode 100644 index 000000000..46d1cdc4f --- /dev/null +++ b/db/routines/vn/procedures/travel_recalc.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) +proc: BEGIN +/** + * Updates the number of entries assigned to the travel. + * + * @param vSelf The travel id + */ + UPDATE travel + SET totalEntries = ( + SELECT COUNT(id) + FROM entry + WHERE travelFk = vSelf + ) + WHERE id = vSelf; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/travel_requestRecalc.sql b/db/routines/vn/procedures/travel_requestRecalc.sql deleted file mode 100644 index 5797f2397..000000000 --- a/db/routines/vn/procedures/travel_requestRecalc.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recount the number of entries for the travel. - * - * @param vSelf The travel reference - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - INSERT IGNORE INTO travelRecalc SET travelFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/address_afterUpdate.sql b/db/routines/vn/triggers/address_afterUpdate.sql index 6160aa2a5..ab5e03882 100644 --- a/db/routines/vn/triggers/address_afterUpdate.sql +++ b/db/routines/vn/triggers/address_afterUpdate.sql @@ -5,36 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterUpdate` BEGIN -- Recargos de equivalencia distintos implican facturacion por consignatario IF NEW.isEqualizated != OLD.isEqualizated THEN - IF + IF (SELECT COUNT(*) FROM ( SELECT DISTINCT (isEqualizated = FALSE) as Equ - FROM address + FROM address WHERE clientFk = NEW.clientFk ) t1 ) > 1 - THEN - UPDATE client + THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; END IF; END IF; + IF NEW.isDefaultAddress AND NEW.isActive = FALSE THEN CALL util.throw ('Cannot desactivate the default address'); END IF; - IF NOT (NEW.isEqualizated <=> OLD.isEqualizated) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.addressFk = NEW.id - AND t.refFk IS NULL; - END IF; - - IF (NEW.clientFk <> OLD.clientFk OR NEW.isActive <> OLD.isActive OR NOT (NEW.provinceFk <=> OLD.provinceFk)) - AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN - UPDATE client + IF (NEW.clientFk <> OLD.clientFk + OR NEW.isActive <> OLD.isActive + OR NOT (NEW.provinceFk <=> OLD.provinceFk)) + AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; - END IF; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_afterUpdate.sql b/db/routines/vn/triggers/client_afterUpdate.sql index 481b00007..8bca36d63 100644 --- a/db/routines/vn/triggers/client_afterUpdate.sql +++ b/db/routines/vn/triggers/client_afterUpdate.sql @@ -4,20 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate` FOR EACH ROW BEGIN IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN - UPDATE `address` SET isDefaultAddress = 0 + UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; - - UPDATE `address` SET isDefaultAddress = 1 - WHERE id = NEW.defaultAddressFk; + + UPDATE `address` SET isDefaultAddress = TRUE + WHERE id = NEW.defaultAddressFk; END IF; - IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.clientFk = NEW.id - AND t.refFk IS NULL; - END IF; - IF NOT NEW.isActive THEN UPDATE account.`user` SET active = FALSE diff --git a/db/routines/vn/triggers/entry_afterDelete.sql b/db/routines/vn/triggers/entry_afterDelete.sql index 5c246651d..c723930fa 100644 --- a/db/routines/vn/triggers/entry_afterDelete.sql +++ b/db/routines/vn/triggers/entry_afterDelete.sql @@ -8,7 +8,5 @@ BEGIN `changedModel` = 'Entry', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL travel_requestRecalc(OLD.travelFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterInsert.sql b/db/routines/vn/triggers/entry_afterInsert.sql deleted file mode 100644 index 79563c17f..000000000 --- a/db/routines/vn/triggers/entry_afterInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterInsert` - AFTER INSERT ON `entry` - FOR EACH ROW -BEGIN - CALL travel_requestRecalc(NEW.travelFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index c2d205768..47d61ed30 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -3,11 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - CALL travel_requestRecalc(OLD.travelFk); - CALL travel_requestRecalc(NEW.travelFk); - END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index da74c05ec..6365208b2 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -12,8 +12,6 @@ BEGIN `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - CALL ticket_requestRecalc(OLD.ticketFk); - SELECT account.myUser_getName() INTO vUserRole; SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index 3ce5ce8d9..b5b28257f 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -7,10 +7,7 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - CALL ticket_requestRecalc(NEW.ticketFk); - IF NEW.quantity > 0 THEN - UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 8500afbe3..3f59c9188 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -6,15 +6,6 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.discount <=> OLD.discount) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; - IF !(OLD.ticketFk <=> NEW.ticketFk) THEN UPDATE ticketRequest SET ticketFk = NEW.ticketFk WHERE saleFk = NEW.id; diff --git a/db/routines/vn/triggers/ticketService_afterDelete.sql b/db/routines/vn/triggers/ticketService_afterDelete.sql index 11d5aaf24..ca2675ce8 100644 --- a/db/routines/vn/triggers/ticketService_afterDelete.sql +++ b/db/routines/vn/triggers/ticketService_afterDelete.sql @@ -8,8 +8,5 @@ BEGIN `changedModel` = 'TicketService', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL ticket_requestRecalc(OLD.ticketFk); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterInsert.sql b/db/routines/vn/triggers/ticketService_afterInsert.sql deleted file mode 100644 index b9142ff72..000000000 --- a/db/routines/vn/triggers/ticketService_afterInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterInsert` - AFTER INSERT ON `ticketService` - FOR EACH ROW -BEGIN - - CALL ticket_requestRecalc(NEW.ticketFk); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterUpdate.sql b/db/routines/vn/triggers/ticketService_afterUpdate.sql deleted file mode 100644 index ecc9e9a5a..000000000 --- a/db/routines/vn/triggers/ticketService_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterUpdate` - AFTER UPDATE ON `ticketService` - FOR EACH ROW -BEGIN - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.quantity <=> OLD.quantity) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index fd4b01571..f1ad394ef 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -3,17 +3,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); - END IF; - IF NEW.routeFk <> OLD.routeFk THEN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; - END$$ DELIMITER ; diff --git a/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql new file mode 100644 index 000000000..13216936b --- /dev/null +++ b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql @@ -0,0 +1 @@ +DROP TABLE hedera.orderRecalc; diff --git a/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql new file mode 100644 index 000000000..e7c765e91 --- /dev/null +++ b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.ticketRecalc; diff --git a/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql new file mode 100644 index 000000000..49b26f83f --- /dev/null +++ b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.travelRecalc; From 32e2827287161a494541f6ff97a8f267c1fe6ba8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Apr 2024 13:55:07 +0200 Subject: [PATCH 36/78] refs #6921 feat: addFromDelivery --- db/dump/fixtures.before.sql | 3 +- ...-firstScript.sql => 00-firstScript.vn.sql} | 2 +- .../methods/ticket-observation/addDropOff.js | 54 +++++++++++++++++++ .../specs/addDropOff.spec.js | 37 +++++++++++++ .../ticket/back/models/ticket-observation.js | 1 + 5 files changed, 95 insertions(+), 2 deletions(-) rename db/versions/10987-tealMonstera/{00-firstScript.sql => 00-firstScript.vn.sql} (87%) create mode 100644 modules/ticket/back/methods/ticket-observation/addDropOff.js create mode 100644 modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8660d61c9..30564d8a2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -527,7 +527,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) (4, 'SalesPerson', 'salesPerson'), (5, 'Administrative', 'administrative'), (6, 'Weight', 'weight'), - (7, 'InvoiceOut', 'invoiceOut'); + (7, 'InvoiceOut', 'invoiceOut'), + (8, 'DropOff', 'dropOff'); INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES diff --git a/db/versions/10987-tealMonstera/00-firstScript.sql b/db/versions/10987-tealMonstera/00-firstScript.vn.sql similarity index 87% rename from db/versions/10987-tealMonstera/00-firstScript.sql rename to db/versions/10987-tealMonstera/00-firstScript.vn.sql index e78d54fd4..d24ddd5de 100644 --- a/db/versions/10987-tealMonstera/00-firstScript.sql +++ b/db/versions/10987-tealMonstera/00-firstScript.vn.sql @@ -1,4 +1,4 @@ -- Place your SQL code here USE vn; -INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff') \ No newline at end of file +INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff'); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket-observation/addDropOff.js b/modules/ticket/back/methods/ticket-observation/addDropOff.js new file mode 100644 index 000000000..52a12a58e --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/addDropOff.js @@ -0,0 +1,54 @@ + +module.exports = Self => { + Self.remoteMethod('addDropOff', { + description: 'Add a dropOff note in a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'ticketFk', + type: 'number', + required: true, + description: 'ticket ID' + }, { + arg: 'note', + type: 'string', + required: true, + description: 'note text' + }], + + http: { + path: `/addDropOff`, + verb: 'post' + } + }); + + Self.addDropOff = async(ticketFk, note, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + try { + const observationTypeDropOff = await models.ObservationType.findOne({ + where: {code: 'dropOff'} + }, myOptions); + + await models.TicketObservation.create({ + ticketFk: ticketFk, + observationTypeFk: observationTypeDropOff.id, + description: note + + }, myOptions); + + if (tx) await tx.commit(); + } catch (error) { + if (tx) await tx.rollback(); + throw error; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js new file mode 100644 index 000000000..1034dbe67 --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js @@ -0,0 +1,37 @@ +const {models} = require('vn-loopback/server/server'); + +describe('ticketObservation addDropOff()', () => { + const ticketFk = 5; + const note = 'DropOff note'; + const code = 'dropOff'; + + it('should return a dropOff note', async() => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await models.TicketObservation.beginTransaction({}); + myOptions.transaction = tx; + } + try { + await models.TicketObservation.addDropOff( + ticketFk, note, myOptions); + + const observationTypeDropOff = await models.TicketObservation.find({ + where: { + ticketFk, + code + } + }, myOptions); + + expect(observationTypeDropOff.length).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/models/ticket-observation.js b/modules/ticket/back/models/ticket-observation.js index 77d15d85c..3076484bf 100644 --- a/modules/ticket/back/models/ticket-observation.js +++ b/modules/ticket/back/models/ticket-observation.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { + require('../methods/ticket-observation/addDropOff')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`The observation type can't be repeated`); From 3f291da02ce8a52654f2707b9f5a08db29265148 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Apr 2024 13:57:56 +0200 Subject: [PATCH 37/78] refs #6921 feat: addFromDelivery --- .../vn/procedures/addNoteFromDelivery.sql | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 7431d4f49..61295b7db 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -1,20 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(vTicketFk INT, vDescription TEXT, vCode VARCHAR(45)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) BEGIN + + DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ - /** - * Inserta observaciones para los tickets - * - * @param vTicketFk Identificador del ticket - * @param vDescription Texto de la nota a insertar - * @param vCode Identificador del tipo de nota - */ + INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) + VALUES (idTicket,observationTypeFk,nota) + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, id, vDescription - FROM vn.observationType - WHERE code = vCode - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description, VALUES(description),' '); END$$ DELIMITER ; From f41177643f8a795e25562954e2d3d0b1ff4d93c3 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 18 Apr 2024 08:01:16 +0200 Subject: [PATCH 38/78] refactor: refs #6899 corrected Lilium styles and functionalities --- .../back/methods/invoiceOut/negativeBases.js | 2 +- .../back/models/cplus-rectification-type.json | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 66440616c..3af1e2fc7 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -70,7 +70,7 @@ module.exports = Self => { c.hasToInvoice, c.isTaxDataChecked, w.id comercialId, - CONCAT(w.firstName, ' ', w.lastName) comercialName + w.firstName AS comercialName FROM vn.ticket t JOIN vn.company co ON co.id = t.companyFk JOIN vn.sale s ON s.ticketFk = t.id diff --git a/modules/invoiceOut/back/models/cplus-rectification-type.json b/modules/invoiceOut/back/models/cplus-rectification-type.json index e7bfb957f..06a57ea67 100644 --- a/modules/invoiceOut/back/models/cplus-rectification-type.json +++ b/modules/invoiceOut/back/models/cplus-rectification-type.json @@ -15,5 +15,13 @@ "description": { "type": "string" } - } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } \ No newline at end of file From e909d647579befa0b0361311f4f5e8c0d4e6b8ad Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 18 Apr 2024 10:01:22 +0200 Subject: [PATCH 39/78] refs #6921 feat: addFromDelivery --- .../methods/ticket-observation/addDropOff.js | 28 ++++++------------- .../specs/addDropOff.spec.js | 14 +++------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/modules/ticket/back/methods/ticket-observation/addDropOff.js b/modules/ticket/back/methods/ticket-observation/addDropOff.js index 52a12a58e..5f773f593 100644 --- a/modules/ticket/back/methods/ticket-observation/addDropOff.js +++ b/modules/ticket/back/methods/ticket-observation/addDropOff.js @@ -24,31 +24,19 @@ module.exports = Self => { Self.addDropOff = async(ticketFk, note, options) => { const models = Self.app.models; const myOptions = {}; - let tx; if (typeof options == 'object') Object.assign(myOptions, options); - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - try { - const observationTypeDropOff = await models.ObservationType.findOne({ - where: {code: 'dropOff'} - }, myOptions); + const observationTypeDropOff = await models.ObservationType.findOne({ + where: {code: 'dropOff'} + }, myOptions); - await models.TicketObservation.create({ - ticketFk: ticketFk, - observationTypeFk: observationTypeDropOff.id, - description: note + await models.TicketObservation.create({ + ticketFk: ticketFk, + observationTypeFk: observationTypeDropOff.id, + description: note - }, myOptions); - - if (tx) await tx.commit(); - } catch (error) { - if (tx) await tx.rollback(); - throw error; - } + }, myOptions); }; }; diff --git a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js index 1034dbe67..82c692946 100644 --- a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js +++ b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js @@ -6,25 +6,19 @@ describe('ticketObservation addDropOff()', () => { const code = 'dropOff'; it('should return a dropOff note', async() => { - const myOptions = {}; + const tx = await models.TicketObservation.beginTransaction({}); - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await models.TicketObservation.beginTransaction({}); - myOptions.transaction = tx; - } try { + const options = {transaction: tx}; await models.TicketObservation.addDropOff( - ticketFk, note, myOptions); + ticketFk, note, options); const observationTypeDropOff = await models.TicketObservation.find({ where: { ticketFk, code } - }, myOptions); + }, options); expect(observationTypeDropOff.length).toEqual(1); From 9295bddaa84bc15c66319d50f3d35b1fee212e61 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Apr 2024 13:06:45 +0200 Subject: [PATCH 40/78] feat: refs #174903 item_getSimilar --- db/routines/vn/procedures/item_getSimilar.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index f79bed375..f7126c1a5 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -65,7 +65,9 @@ BEGIN WHEN b.groupingMode = 2 THEN b.packing ELSE 1 END AS minQuantity, - iss.visible located + iss.visible located, + b.price2, + b.price3 FROM vn.item i JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalcFk From 067e71e3ce0ff545cc1a38e8b97148e9438dcf31 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 07:48:45 +0200 Subject: [PATCH 41/78] feat: refs #6777 puppeteer --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index d700ce1f9..bfe31fc60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,7 @@ pipeline { stage('Back') { steps { sh 'pnpm install --prefer-offline' + sh 'node node_modules/puppeteer/install.mjs' } } stage('Print') { From f40c730f6ec4c0583663e638db7f687595e12ea1 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 19 Apr 2024 07:52:43 +0200 Subject: [PATCH 42/78] refactor: refs #6899 changed comercial value in negativeBases --- modules/invoiceOut/back/methods/invoiceOut/negativeBases.js | 2 +- modules/invoiceOut/front/negative-bases/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 3af1e2fc7..6c3fdd075 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -70,7 +70,7 @@ module.exports = Self => { c.hasToInvoice, c.isTaxDataChecked, w.id comercialId, - w.firstName AS comercialName + u.name workerSocial FROM vn.ticket t JOIN vn.company co ON co.id = t.companyFk JOIN vn.sale s ON s.ticketFk = t.id diff --git a/modules/invoiceOut/front/negative-bases/index.html b/modules/invoiceOut/front/negative-bases/index.html index 26f67c7d4..c88aa2f4f 100644 --- a/modules/invoiceOut/front/negative-bases/index.html +++ b/modules/invoiceOut/front/negative-bases/index.html @@ -114,7 +114,7 @@ - {{::client.comercialName | dashIfEmpty}} + {{::client.workerSocial | dashIfEmpty}} From 322d91d81404f5d2d5ec001749ca9f7a639ea180 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 10:49:57 +0200 Subject: [PATCH 43/78] feat(salix): refs #6930 Add DEFAULT scope --- back/methods/dms/downloadFile.js | 2 +- back/methods/docuware/download.js | 2 +- back/methods/image/download.js | 2 +- modules/claim/back/methods/claim/claimPickupPdf.js | 2 +- modules/claim/back/methods/claim/downloadFile.js | 2 +- modules/client/back/methods/client/campaignMetricsPdf.js | 2 +- modules/entry/back/methods/entry/entryOrderPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/download.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/downloadZip.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js | 2 +- modules/item/back/methods/item-image-queue/download.js | 2 +- modules/route/back/methods/route/cmr.js | 2 +- modules/route/back/methods/route/downloadCmrsZip.js | 2 +- modules/route/back/methods/route/downloadZip.js | 2 +- modules/route/back/methods/route/driverRoutePdf.js | 2 +- modules/supplier/back/methods/supplier/campaignMetricsPdf.js | 2 +- modules/ticket/back/methods/ticket/deliveryNoteCsv.js | 2 +- modules/ticket/back/methods/ticket/deliveryNotePdf.js | 2 +- modules/travel/back/methods/travel/extraCommunityPdf.js | 2 +- modules/worker/back/methods/worker-dms/downloadFile.js | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index d64b15b70..9290188a1 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index a1776cde5..eb575236d 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -43,7 +43,7 @@ module.exports = Self => { path: `/:id/download`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 201e16164..e0fcb0951 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -48,7 +48,7 @@ module.exports = Self => { path: `/:collection/:size/:id/download`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 4b66bd418..232c134f6 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/claim-pickup-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 61784f39e..ffcf51367 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -33,7 +33,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index 20c35494e..dc89a6802 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -46,7 +46,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index 93c1b6bd9..7a432123e 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -34,7 +34,7 @@ module.exports = Self => { path: '/:id/entry-order-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index cb71121d5..748e2df17 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/:id/download', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 4f2a8aab3..8d6e7c6d9 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index 0b08aec6d..6c4845c11 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:reference/exportation-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index 6822e5a23..fd754d51b 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:reference/invoice-csv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.invoiceCsv = async reference => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 6ac56b68c..3e466d1f4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -40,7 +40,7 @@ module.exports = Self => { path: '/negativeBasesCsv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index e1bc248ae..001a2b950 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,7 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index 08a8182e0..5033dee2f 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/:id/cmr', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 43f6e9648..c6934edca 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadCmrsZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index d7fc30aa3..8eecf62e4 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index e7b4dee17..69b26d846 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/driver-route-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 51c626e69..58282747d 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -45,7 +45,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 9fa3c183e..f02debba8 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:id/delivery-note-csv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNoteCsv = async id => { diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index adc9e4435..205f4ba7b 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -42,7 +42,7 @@ module.exports = Self => { path: '/:id/delivery-note-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 73748ac50..459e74d69 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -79,7 +79,7 @@ module.exports = Self => { path: '/extra-community-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index 08fbcf924..93d685429 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From 30d0db163e875f158c049bb08a383c45a7e52d71 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 10:50:14 +0200 Subject: [PATCH 44/78] feat(salix): refs #6930 minor updates --- .../methods/vn-user/specs/renew-token.spec.js | 5 +- loopback/locale/en.json | 433 +++++++++--------- modules/worker/back/models/worker.json | 4 +- 3 files changed, 223 insertions(+), 219 deletions(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 741388bf9..70e7473d1 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -28,6 +28,9 @@ describe('Renew Token', () => { }); it('should renew token', async() => { + const {courtesyTime} = await models.AccessTokenConfig.findOne({ + fields: ['courtesyTime'] + }); const mockDate = new Date(startingTime + 26600000); jasmine.clock().mockDate(mockDate); const {id} = await models.VnUser.renewToken(ctx); @@ -35,7 +38,7 @@ describe('Renew Token', () => { expect(id).not.toEqual(ctx.req.accessToken.id); await models.VnUser.logout(ctx.req.accessToken.id); - jasmine.clock().tick(70 * 1000); + jasmine.clock().tick((courtesyTime + 10) * 1000); let tokenNotExists; try { tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a0e60550f..9a3a1f52a 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -1,217 +1,217 @@ { - "State cannot be blank": "State cannot be blank", - "Cannot be blank": "Cannot be blank", - "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", - "Invalid email": "Invalid email", - "Name cannot be blank": "Name cannot be blank", - "Phone cannot be blank": "Phone cannot be blank", - "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", - "Period cannot be blank": "Period cannot be blank", - "Sample type cannot be blank": "Sample type cannot be blank", - "That payment method requires an IBAN": "That payment method requires an IBAN", - "That payment method requires a BIC": "That payment method requires a BIC", - "The default consignee can not be unchecked": "The default consignee can not be unchecked", - "Enter an integer different to zero": "Enter an integer different to zero", - "Package cannot be blank": "Package cannot be blank", - "The price of the item changed": "The price of the item changed", - "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", - "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", - "You can't create an order for a frozen client": "You can't create an order for a frozen client", - "This address doesn't exist": "This address doesn't exist", - "Warehouse cannot be blank": "Warehouse cannot be blank", - "Agency cannot be blank": "Agency cannot be blank", - "The IBAN does not have the correct format": "The IBAN does not have the correct format", - "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", - "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", - "Worker cannot be blank": "Worker cannot be blank", - "You must delete the claim id %d first": "You must delete the claim id %d first", - "You don't have enough privileges": "You don't have enough privileges", - "Tag value cannot be blank": "Tag value cannot be blank", - "A client with that Web User name already exists": "A client with that Web User name already exists", - "The warehouse can't be repeated": "The warehouse can't be repeated", - "Barcode must be unique": "Barcode must be unique", - "You don't have enough privileges to do that": "You don't have enough privileges to do that", - "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", - "can't be blank": "can't be blank", - "Street cannot be empty": "Street cannot be empty", - "City cannot be empty": "City cannot be empty", - "EXTENSION_INVALID_FORMAT": "Invalid extension", - "The secret can't be blank": "The secret can't be blank", - "Invalid TIN": "Invalid Tax number", - "This ticket can't be invoiced": "This ticket can't be invoiced", - "The value should be a number": "The value should be a number", - "The current ticket can't be modified": "The current ticket can't be modified", - "Extension format is invalid": "Extension format is invalid", - "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", - "This client can't be invoiced": "This client can't be invoiced", - "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", - "The introduced hour already exists": "The introduced hour already exists", - "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", - "Concept cannot be blank": "Concept cannot be blank", - "Ticket id cannot be blank": "Ticket id cannot be blank", - "Weekday cannot be blank": "Weekday cannot be blank", - "This ticket can not be modified": "This ticket can not be modified", - "You can't delete a confirmed order": "You can't delete a confirmed order", - "Value has an invalid format": "Value has an invalid format", - "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", - "Swift / BIC can't be empty": "Swift / BIC can't be empty", - "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", - "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", - "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", - "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", - "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", - "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", - "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", - "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", - "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "The grade must be similar to the last one": "The grade must be similar to the last one", - "agencyModeFk": "Agency", - "clientFk": "Client", - "zoneFk": "Zone", - "warehouseFk": "Warehouse", - "shipped": "Shipped", - "landed": "Landed", - "addressFk": "Address", - "companyFk": "Company", - "agency": "Agency", - "delivery": "Delivery", - "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", - "The social name cannot be empty": "The social name cannot be empty", - "The nif cannot be empty": "The nif cannot be empty", - "Amount cannot be zero": "Amount cannot be zero", - "Company has to be official": "Company has to be official", - "Unable to clone this travel": "Unable to clone this travel", - "The observation type can't be repeated": "The observation type can't be repeated", - "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", - "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", - "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", - "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "None", - "error densidad = 0": "error densidad = 0", - "This document already exists on this ticket": "This document already exists on this ticket", - "serial non editable": "This serial doesn't allow to set a reference", - "nickname": "nickname", - "State": "State", - "regular": "regular", - "reserved": "reserved", - "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", - "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", - "This client is not invoiceable": "This client is not invoiceable", - "INACTIVE_PROVIDER": "Inactive provider", - "reference duplicated": "reference duplicated", - "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", - "This item is not available": "This item is not available", - "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", - "The type of business must be filled in basic data": "The type of business must be filled in basic data", - "The worker has hours recorded that day": "The worker has hours recorded that day", - "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk", - "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", - "Can't change the password of another worker": "Can't change the password of another worker", - "No hay un contrato en vigor": "There is no existing contract", - "No está permitido trabajar": "Not allowed to work", - "Dirección incorrecta": "Wrong direction", - "No se permite fichar a futuro": "It is not allowed to sign in the future", - "Descanso diario 12h.": "Daily rest 12h.", - "Fichadas impares": "Odd signs", - "Descanso diario 9h.": "Daily rest 9h.", - "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", - "Verify email": "Verify email", - "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", - "Password does not meet requirements": "Password does not meet requirements", - "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", - "Not enough privileges to edit a client": "Not enough privileges to edit a client", - "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", - "You don't have grant privilege": "You don't have grant privilege", - "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", - "Email verify": "Email verify", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "App locked": "App locked by user {{userId}}", - "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", - "Receipt's bank was not found": "Receipt's bank was not found", - "This receipt was not compensated": "This receipt was not compensated", - "Client's email was not found": "Client's email was not found", - "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", - "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", - "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", - "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", - "Warehouse inventory not set": "Almacén inventario no está establecido", - "Component cost not set": "Componente coste no está estabecido", - "Description cannot be blank": "Description cannot be blank", - "company": "Company", - "country": "Country", - "clientId": "Id client", - "clientSocialName": "Client", - "amount": "Amount", - "taxableBase": "Taxable base", - "ticketFk": "Id ticket", - "isActive": "Active", - "hasToInvoice": "Invoice", - "isTaxDataChecked": "Data checked", - "comercialId": "Id Comercial", - "comercialName": "Comercial", - "Added observation": "Added observation", - "Comment added to client": "Comment added to client", - "This ticket is already a refund": "This ticket is already a refund", - "A claim with that sale already exists": "A claim with that sale already exists", - "Pass expired": "The password has expired, change it from Salix", - "Can't transfer claimed sales": "Can't transfer claimed sales", - "Invalid quantity": "Invalid quantity", - "Failed to upload delivery note": "Error to upload delivery note {{id}}", - "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", - "The renew period has not been exceeded": "The renew period has not been exceeded", - "You can not use the same password": "You can not use the same password", - "Valid priorities": "Valid priorities: %d", - "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", - "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", - "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", - "Social name should be uppercase": "Social name should be uppercase", - "Street should be uppercase": "Street should be uppercase", - "You don't have enough privileges.": "You don't have enough privileges.", - "This ticket is locked": "This ticket is locked", - "This ticket is not editable.": "This ticket is not editable.", - "The ticket doesn't exist.": "The ticket doesn't exist.", - "The sales do not exists": "The sales do not exists", - "Ticket without Route": "Ticket without route", - "Select a different client": "Select a different client", - "Fill all the fields": "Fill all the fields", - "Error while generating PDF": "Error while generating PDF", - "Can't invoice to future": "Can't invoice to future", - "This ticket is already invoiced": "This ticket is already invoiced", - "Negative basis of tickets: 23": "Negative basis of tickets: 23", - "Booking completed": "Booking complete", - "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", - "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", - "Bank entity must be specified": "Bank entity must be specified", - "Try again": "Try again", - "keepPrice": "keepPrice", - "Cannot past travels with entries": "Cannot past travels with entries", - "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", - "Incorrect pin": "Incorrect pin.", - "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", - "Name should be uppercase": "Name should be uppercase", - "You cannot update these fields": "You cannot update these fields", - "CountryFK cannot be empty": "Country cannot be empty", - "You are not allowed to modify the alias": "You are not allowed to modify the alias", - "You already have the mailAlias": "You already have the mailAlias", + "State cannot be blank": "State cannot be blank", + "Cannot be blank": "Cannot be blank", + "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", + "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", + "Invalid email": "Invalid email", + "Name cannot be blank": "Name cannot be blank", + "Phone cannot be blank": "Phone cannot be blank", + "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", + "Period cannot be blank": "Period cannot be blank", + "Sample type cannot be blank": "Sample type cannot be blank", + "That payment method requires an IBAN": "That payment method requires an IBAN", + "That payment method requires a BIC": "That payment method requires a BIC", + "The default consignee can not be unchecked": "The default consignee can not be unchecked", + "Enter an integer different to zero": "Enter an integer different to zero", + "Package cannot be blank": "Package cannot be blank", + "The price of the item changed": "The price of the item changed", + "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", + "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", + "You can't create an order for a frozen client": "You can't create an order for a frozen client", + "This address doesn't exist": "This address doesn't exist", + "Warehouse cannot be blank": "Warehouse cannot be blank", + "Agency cannot be blank": "Agency cannot be blank", + "The IBAN does not have the correct format": "The IBAN does not have the correct format", + "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", + "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", + "Worker cannot be blank": "Worker cannot be blank", + "You must delete the claim id %d first": "You must delete the claim id %d first", + "You don't have enough privileges": "You don't have enough privileges", + "Tag value cannot be blank": "Tag value cannot be blank", + "A client with that Web User name already exists": "A client with that Web User name already exists", + "The warehouse can't be repeated": "The warehouse can't be repeated", + "Barcode must be unique": "Barcode must be unique", + "You don't have enough privileges to do that": "You don't have enough privileges to do that", + "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", + "can't be blank": "can't be blank", + "Street cannot be empty": "Street cannot be empty", + "City cannot be empty": "City cannot be empty", + "EXTENSION_INVALID_FORMAT": "Invalid extension", + "The secret can't be blank": "The secret can't be blank", + "Invalid TIN": "Invalid Tax number", + "This ticket can't be invoiced": "This ticket can't be invoiced", + "The value should be a number": "The value should be a number", + "The current ticket can't be modified": "The current ticket can't be modified", + "Extension format is invalid": "Extension format is invalid", + "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", + "This client can't be invoiced": "This client can't be invoiced", + "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", + "The introduced hour already exists": "The introduced hour already exists", + "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", + "Concept cannot be blank": "Concept cannot be blank", + "Ticket id cannot be blank": "Ticket id cannot be blank", + "Weekday cannot be blank": "Weekday cannot be blank", + "This ticket can not be modified": "This ticket can not be modified", + "You can't delete a confirmed order": "You can't delete a confirmed order", + "Value has an invalid format": "Value has an invalid format", + "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", + "Swift / BIC can't be empty": "Swift / BIC can't be empty", + "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", + "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", + "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", + "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", + "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", + "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", + "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", + "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", + "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", + "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "The grade must be similar to the last one": "The grade must be similar to the last one", + "agencyModeFk": "Agency", + "clientFk": "Client", + "zoneFk": "Zone", + "warehouseFk": "Warehouse", + "shipped": "Shipped", + "landed": "Landed", + "addressFk": "Address", + "companyFk": "Company", + "agency": "Agency", + "delivery": "Delivery", + "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", + "The social name cannot be empty": "The social name cannot be empty", + "The nif cannot be empty": "The nif cannot be empty", + "Amount cannot be zero": "Amount cannot be zero", + "Company has to be official": "Company has to be official", + "Unable to clone this travel": "Unable to clone this travel", + "The observation type can't be repeated": "The observation type can't be repeated", + "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", + "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", + "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", + "Role name must be written in camelCase": "Role name must be written in camelCase", + "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "None", + "error densidad = 0": "error densidad = 0", + "This document already exists on this ticket": "This document already exists on this ticket", + "serial non editable": "This serial doesn't allow to set a reference", + "nickname": "nickname", + "State": "State", + "regular": "regular", + "reserved": "reserved", + "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", + "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", + "This client is not invoiceable": "This client is not invoiceable", + "INACTIVE_PROVIDER": "Inactive provider", + "reference duplicated": "reference duplicated", + "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", + "This item is not available": "This item is not available", + "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", + "The type of business must be filled in basic data": "The type of business must be filled in basic data", + "The worker has hours recorded that day": "The worker has hours recorded that day", + "isWithoutNegatives": "isWithoutNegatives", + "routeFk": "routeFk", + "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", + "Can't change the password of another worker": "Can't change the password of another worker", + "No hay un contrato en vigor": "There is no existing contract", + "No está permitido trabajar": "Not allowed to work", + "Dirección incorrecta": "Wrong direction", + "No se permite fichar a futuro": "It is not allowed to sign in the future", + "Descanso diario 12h.": "Daily rest 12h.", + "Fichadas impares": "Odd signs", + "Descanso diario 9h.": "Daily rest 9h.", + "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", + "Verify email": "Verify email", + "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", + "Password does not meet requirements": "Password does not meet requirements", + "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", + "Not enough privileges to edit a client": "Not enough privileges to edit a client", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", + "You don't have grant privilege": "You don't have grant privilege", + "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", + "Email verify": "Email verify", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "App locked": "App locked by user {{userId}}", + "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", + "Receipt's bank was not found": "Receipt's bank was not found", + "This receipt was not compensated": "This receipt was not compensated", + "Client's email was not found": "Client's email was not found", + "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", + "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", + "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Warehouse inventory not set": "Almacén inventario no está establecido", + "Component cost not set": "Componente coste no está estabecido", + "Description cannot be blank": "Description cannot be blank", + "company": "Company", + "country": "Country", + "clientId": "Id client", + "clientSocialName": "Client", + "amount": "Amount", + "taxableBase": "Taxable base", + "ticketFk": "Id ticket", + "isActive": "Active", + "hasToInvoice": "Invoice", + "isTaxDataChecked": "Data checked", + "comercialId": "Id Comercial", + "comercialName": "Comercial", + "Added observation": "Added observation", + "Comment added to client": "Comment added to client", + "This ticket is already a refund": "This ticket is already a refund", + "A claim with that sale already exists": "A claim with that sale already exists", + "Pass expired": "The password has expired, change it from Salix", + "Can't transfer claimed sales": "Can't transfer claimed sales", + "Invalid quantity": "Invalid quantity", + "Failed to upload delivery note": "Error to upload delivery note {{id}}", + "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", + "The renew period has not been exceeded": "The renew period has not been exceeded", + "You can not use the same password": "You can not use the same password", + "Valid priorities": "Valid priorities: %d", + "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", + "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", + "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", + "Social name should be uppercase": "Social name should be uppercase", + "Street should be uppercase": "Street should be uppercase", + "You don't have enough privileges.": "You don't have enough privileges.", + "This ticket is locked": "This ticket is locked", + "This ticket is not editable.": "This ticket is not editable.", + "The ticket doesn't exist.": "The ticket doesn't exist.", + "The sales do not exists": "The sales do not exists", + "Ticket without Route": "Ticket without route", + "Select a different client": "Select a different client", + "Fill all the fields": "Fill all the fields", + "Error while generating PDF": "Error while generating PDF", + "Can't invoice to future": "Can't invoice to future", + "This ticket is already invoiced": "This ticket is already invoiced", + "Negative basis of tickets: 23": "Negative basis of tickets: 23", + "Booking completed": "Booking complete", + "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", + "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", + "Bank entity must be specified": "Bank entity must be specified", + "Try again": "Try again", + "keepPrice": "keepPrice", + "Cannot past travels with entries": "Cannot past travels with entries", + "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", + "Incorrect pin": "Incorrect pin.", + "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", + "Name should be uppercase": "Name should be uppercase", + "You cannot update these fields": "You cannot update these fields", + "CountryFK cannot be empty": "Country cannot be empty", + "You are not allowed to modify the alias": "You are not allowed to modify the alias", + "You already have the mailAlias": "You already have the mailAlias", "This machine is already in use.": "This machine is already in use.", "the plate does not exist": "The plate {{plate}} does not exist", "We do not have availability for the selected item": "We do not have availability for the selected item", @@ -223,6 +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/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 57dc80ec9..f959d3138 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk"], + "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified","recoveryPhone"], "include": [ { "relation": "role", @@ -127,7 +127,7 @@ }, { "relation": "client", "scope": { - "fields": [ + "fields": [ "id", "name", "fi", From fb17a54ebd3ac6cf431acd648b37b396dcedc1c0 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 10:53:03 +0200 Subject: [PATCH 45/78] feat: refs #6777 resotre view --- db/routines/vn2008/views/tblContadores.sql | 39 +++++++++++++++++++ db/routines/vn2008/views/thermograph.sql | 6 +++ .../vn2008/views/ticket_observation.sql | 8 ++++ db/routines/vn2008/views/tickets_gestdoc.sql | 6 +++ 4 files changed, 59 insertions(+) create mode 100644 db/routines/vn2008/views/tblContadores.sql create mode 100644 db/routines/vn2008/views/thermograph.sql create mode 100644 db/routines/vn2008/views/ticket_observation.sql create mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql new file mode 100644 index 000000000..129d3ce8b --- /dev/null +++ b/db/routines/vn2008/views/tblContadores.sql @@ -0,0 +1,39 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tblContadores` +AS SELECT `c`.`id` AS `id`, + `c`.`ochoa` AS `ochoa`, + `c`.`invoiceOutFk` AS `nfactura`, + `c`.`inventoried` AS `FechaInventario`, + `c`.`itemLog` AS `HistoricoArticulo`, + `c`.`weekGoal` AS `week_goal`, + `c`.`photosPath` AS `Rutafotos`, + `c`.`cashBoxNumber` AS `numCaja`, + `c`.`redCode` AS `CodigoRojo`, + `c`.`TabletTime` AS `Tablet_Hora`, + `c`.`t0` AS `t0`, + `c`.`t1` AS `t1`, + `c`.`t2` AS `t2`, + `c`.`t3` AS `t3`, + `c`.`cc` AS `cc`, + `c`.`palet` AS `palet`, + `c`.`campaign` AS `campaign`, + `c`.`campaignLife` AS `campaign_life`, + `c`.`truckDays` AS `truck_days`, + `c`.`transportCharges` AS `tasa_transporte`, + `c`.`escanerPath` AS `escaner_path`, + `c`.`printedTurn` AS `turnoimpreso`, + `c`.`truckLength` AS `truck_length`, + `c`.`fuelConsumption` AS `fuel_consumption`, + `c`.`petrol` AS `petrol`, + `c`.`maintenance` AS `maintenance`, + `c`.`hourPrice` AS `hour_price`, + `c`.`meterPrice` AS `meter_price`, + `c`.`kmPrice` AS `km_price`, + `c`.`routeOption` AS `route_option`, + `c`.`dbproduccion` AS `dbproduccion`, + `c`.`mdbServer` AS `mdbServer`, + `c`.`fakeEmail` AS `fakeEmail`, + `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, + `c`.`ASIEN` AS `ASIEN` +FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql new file mode 100644 index 000000000..f51b83d24 --- /dev/null +++ b/db/routines/vn2008/views/thermograph.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`thermograph` +AS SELECT `t`.`id` AS `thermograph_id`, + `t`.`model` AS `model` +FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql new file mode 100644 index 000000000..deb85e4b6 --- /dev/null +++ b/db/routines/vn2008/views/ticket_observation.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`ticket_observation` +AS SELECT `to`.`id` AS `ticket_observation_id`, + `to`.`ticketFk` AS `Id_Ticket`, + `to`.`observationTypeFk` AS `observation_type_id`, + `to`.`description` AS `text` +FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql new file mode 100644 index 000000000..a8682db57 --- /dev/null +++ b/db/routines/vn2008/views/tickets_gestdoc.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tickets_gestdoc` +AS SELECT `td`.`ticketFk` AS `Id_Ticket`, + `td`.`dmsFk` AS `gestdoc_id` +FROM `vn`.`ticketDms` `td` From e601310d3e347281535d2031ce0b9e9ecdd372e2 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:27:54 +0200 Subject: [PATCH 46/78] feat: refs #6777 restore view --- db/routines/vn2008/views/Rutas.sql | 19 +++++++++++++++++++ db/routines/vn2008/views/Tickets_turno.sql | 6 ++++++ db/routines/vn2008/views/state.sql | 13 +++++++++++++ db/routines/vn2008/views/tag.sql | 10 ++++++++++ .../vn2008/views/tarifa_componentes.sql | 10 ++++++++++ .../views/tarifa_componentes_series.sql | 7 +++++++ 6 files changed, 65 insertions(+) create mode 100644 db/routines/vn2008/views/Rutas.sql create mode 100644 db/routines/vn2008/views/Tickets_turno.sql create mode 100644 db/routines/vn2008/views/state.sql create mode 100644 db/routines/vn2008/views/tag.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql new file mode 100644 index 000000000..78b3bb471 --- /dev/null +++ b/db/routines/vn2008/views/Rutas.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Rutas` +AS SELECT `r`.`id` AS `Id_Ruta`, + `r`.`workerFk` AS `Id_Trabajador`, + `r`.`created` AS `Fecha`, + `r`.`vehicleFk` AS `Id_Vehiculo`, + `r`.`agencyModeFk` AS `Id_Agencia`, + `r`.`time` AS `Hora`, + `r`.`isOk` AS `ok`, + `r`.`kmStart` AS `km_start`, + `r`.`kmEnd` AS `km_end`, + `r`.`started` AS `date_start`, + `r`.`finished` AS `date_end`, + `r`.`gestdocFk` AS `gestdoc_id`, + `r`.`cost` AS `cost`, + `r`.`m3` AS `m3`, + `r`.`description` AS `description` +FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql new file mode 100644 index 000000000..28bc2d55f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_turno.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_turno` +AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, + `tw`.`weekDay` AS `weekDay` +FROM `vn`.`ticketWeekly` `tw` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql new file mode 100644 index 000000000..63f6589af --- /dev/null +++ b/db/routines/vn2008/views/state.sql @@ -0,0 +1,13 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`state` +AS SELECT `s`.`id` AS `id`, + `s`.`name` AS `name`, + `s`.`order` AS `order`, + `s`.`alertLevel` AS `alert_level`, + `s`.`code` AS `code`, + `s`.`sectorProdPriority` AS `sectorProdPriority`, + `s`.`nextStateFk` AS `nextStateFk`, + `s`.`isPreviousPreparable` AS `isPreviousPreparable`, + `s`.`isPicked` AS `isPicked` +FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql new file mode 100644 index 000000000..25b3ab82e --- /dev/null +++ b/db/routines/vn2008/views/tag.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tag` +AS SELECT `t`.`id` AS `id`, + `t`.`name` AS `name`, + `t`.`isFree` AS `isFree`, + `t`.`isQuantitatif` AS `isQuantitatif`, + `t`.`sourceTable` AS `sourceTable`, + `t`.`unit` AS `unit` +FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql new file mode 100644 index 000000000..bec53abd9 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes` +AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, + `tarifa_componentes`.`Componente` AS `Componente`, + `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, + `tarifa_componentes`.`tax` AS `tax`, + `tarifa_componentes`.`is_renewable` AS `is_renewable` +FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql new file mode 100644 index 000000000..a1d188709 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes_series.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes_series` +AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes_series`.`Serie` AS `Serie`, + `tarifa_componentes_series`.`base` AS `base` +FROM `bi`.`tarifa_componentes_series` From 5b027a88fa20d99329cf42cc4a7b654bb982884a Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:33:33 +0200 Subject: [PATCH 47/78] feat: refs #6777 restore view --- db/routines/vn2008/views/Tickets_state.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/routines/vn2008/views/Tickets_state.sql diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql new file mode 100644 index 000000000..be59a750f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_state.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_state` +AS SELECT `t`.`ticketFk` AS `Id_Ticket`, + `t`.`ticketTrackingFk` AS `inter_id`, + `t`.`name` AS `state_name` +FROM `vn`.`ticketLastState` `t` From d2aba88a345c2c8202c5c19f3c8c23141cf5228b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 11:36:34 +0200 Subject: [PATCH 48/78] feat(salix): refs #7190 minor change salix-back --- back/methods/vn-user/renew-token.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index 2fd1f43c0..8e5ffc095 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -12,8 +12,8 @@ module.exports = Self => { http: { path: `/renewToken`, verb: 'POST' - } - }); + }, + accessScopes: ['DEFAULT', 'read:multimedia']}); Self.renewToken = async function(ctx) { const {accessToken: token} = ctx.req; From 329f875640f3121910380c07a7789d5f4672c726 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 11:36:49 +0200 Subject: [PATCH 49/78] feat(salix): refs #7190 Call renewtoken with tokenMultimedia --- front/core/services/token.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/front/core/services/token.js b/front/core/services/token.js index 125de6b9a..6858bcae9 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -1,5 +1,6 @@ import ngModule from '../module'; - +const TOKEN_MULTIMEDIA = 'vnTokenMultimedia'; +const TOKEN = 'vnToken'; /** * Saves and loads the token for the current logged in user. * @@ -58,8 +59,8 @@ export default class Token { } getStorage(storage) { - this.token = storage.getItem('vnToken'); - this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); + this.token = storage.getItem(TOKEN); + this.tokenMultimedia = storage.getItem(TOKEN_MULTIMEDIA); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); @@ -67,15 +68,15 @@ export default class Token { } setStorage(storage, token, tokenMultimedia, created, ttl) { - storage.setItem('vnTokenMultimedia', tokenMultimedia); - storage.setItem('vnToken', token); + storage.setItem(TOKEN_MULTIMEDIA, tokenMultimedia); + storage.setItem(TOKEN, token); storage.setItem('vnTokenCreated', created.toJSON()); storage.setItem('vnTokenTtl', ttl); } removeStorage(storage) { - storage.removeItem('vnToken'); - storage.removeItem('vnTokenMultimedia'); + storage.removeItem(TOKEN); + storage.removeItem(TOKEN_MULTIMEDIA); storage.removeItem('vnTokenCreated'); storage.removeItem('vnTokenTtl'); } @@ -96,9 +97,9 @@ export default class Token { this.checking = true; const renewPeriod = Math.min(this.ttl, this.renewPeriod) * 1000; const maxDate = this.created.getTime() + renewPeriod; - const now = new Date(); + const now = new Date().getTime(); - if (now.getTime() <= maxDate) { + if (now <= maxDate) { this.checking = false; return; } @@ -106,7 +107,17 @@ export default class Token { this.$http.post('VnUsers/renewToken') .then(res => { const token = res.data; - this.set(token.id, now, token.ttl, this.remember); + const tokenMultimedia = + localStorage.getItem(TOKEN_MULTIMEDIA) + ?? sessionStorage.getItem(TOKEN_MULTIMEDIA); + + return this.$http.post('VnUsers/renewToken', null, { + headers: {Authorization: tokenMultimedia} + }) + .then(({data}) => { + const tokenMultimedia = data; + this.set(token.id, tokenMultimedia.id, new Date(), token.ttl, this.remember); + }); }) .finally(() => { this.checking = false; @@ -119,4 +130,4 @@ export default class Token { } Token.$inject = ['vnInterceptor', '$http', '$rootScope']; -ngModule.service('vnToken', Token); +ngModule.service(TOKEN, Token); From e6258dc9e548fa6ffab681dbee6f62ce44e2210d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 19 Apr 2024 13:03:57 +0200 Subject: [PATCH 50/78] refs #6413 hotFix fix:ubicadorChecking --- db/routines/vn/procedures/itemShelving_addList.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql index c07dd985c..130007de5 100644 --- a/db/routines/vn/procedures/itemShelving_addList.sql +++ b/db/routines/vn/procedures/itemShelving_addList.sql @@ -39,7 +39,7 @@ BEGIN UPDATE vn.itemShelving SET isChecked = vIsChecked WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk; + AND itemFk = vItemFk AND isChecked IS NULL; SET vCounter = vCounter + 1; END WHILE; From ad317cb5e545f5c53bded7269823ec14c7047bc2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 19 Apr 2024 14:11:35 +0200 Subject: [PATCH 51/78] refs #7021 Delete rfid schema --- db/versions/11003-greenRoebelini/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11003-greenRoebelini/00-firstScript.sql diff --git a/db/versions/11003-greenRoebelini/00-firstScript.sql b/db/versions/11003-greenRoebelini/00-firstScript.sql new file mode 100644 index 000000000..97c5f355f --- /dev/null +++ b/db/versions/11003-greenRoebelini/00-firstScript.sql @@ -0,0 +1 @@ +DROP SCHEMA IF EXISTS rfid; From a0126748e2e3da3a2085d887e9cffea36a098ede Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 19 Apr 2024 14:19:34 +0200 Subject: [PATCH 52/78] fix(binlog): refs #4409 Fix fixtures cursor name --- db/dump/fixtures.before.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 353d4f3e0..ca34284da 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2624,18 +2624,18 @@ BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; - DECLARE cCur CURSOR FOR SELECT id FROM vn.ticket; + DECLARE cTickets CURSOR FOR SELECT id FROM vn.ticket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cCur; + OPEN cTickets; myLoop: LOOP SET vDone = FALSE; - FETCH cCur INTO vTicketFk; + FETCH cTickets INTO vTicketFk; IF vDone THEN LEAVE myLoop; END IF; CALL vn.ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cCur; + CLOSE cTickets; END$$ DELIMITER ; From 0615510a9cc7a4090da2e3474ed45c70ef319055 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 19 Apr 2024 15:28:53 +0200 Subject: [PATCH 53/78] refs #7021 Modify myt.config.yml --- myt.config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/myt.config.yml b/myt.config.yml index 2ac8b8e5e..d94913b05 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -15,7 +15,6 @@ schemas: - hedera - pbx - psico - - rfid - sage - salix - srt From 9759ee4bd00e68cd46b91d374076372686a18d4b Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 22 Apr 2024 07:37:47 +0200 Subject: [PATCH 54/78] refactor: refs #6899 requested changes --- modules/invoiceOut/back/methods/invoiceOut/negativeBases.js | 2 +- modules/invoiceOut/front/negative-bases/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 6c3fdd075..fc8830885 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -70,7 +70,7 @@ module.exports = Self => { c.hasToInvoice, c.isTaxDataChecked, w.id comercialId, - u.name workerSocial + u.name workerName FROM vn.ticket t JOIN vn.company co ON co.id = t.companyFk JOIN vn.sale s ON s.ticketFk = t.id diff --git a/modules/invoiceOut/front/negative-bases/index.html b/modules/invoiceOut/front/negative-bases/index.html index c88aa2f4f..499b6bfe0 100644 --- a/modules/invoiceOut/front/negative-bases/index.html +++ b/modules/invoiceOut/front/negative-bases/index.html @@ -114,7 +114,7 @@ - {{::client.workerSocial | dashIfEmpty}} + {{::client.workerName | dashIfEmpty}} From 283d27e1c5b5a7402fe312127f115bf848abf180 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Apr 2024 06:22:36 +0000 Subject: [PATCH 55/78] Actualizar modules/worker/back/models/worker.json --- modules/worker/back/models/worker.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index f959d3138..c9db0aeee 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified","recoveryPhone"], + "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified"], "include": [ { "relation": "role", From f6199f8f8ede30cf3097d8a4de14780bb41cd107 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Apr 2024 06:56:05 +0000 Subject: [PATCH 56/78] Actualizar modules/worker/back/models/worker.json --- modules/worker/back/models/worker.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c9db0aeee..c203f6e09 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified"], + "fields": ["email", "name", "nickname", "roleFk", "emailVerified"], "include": [ { "relation": "role", From 739ae82ace3c34c9737bd7269376b3ce06ad1a59 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 22 Apr 2024 09:02:43 +0200 Subject: [PATCH 57/78] fix(binlog): refs #4409 Fix cursor name --- db/routines/util/functions/binlogQueue_getDelay.sql | 1 + db/routines/vn/procedures/ticket_recalcByScope.sql | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql index a440fc0ab..d6cf49377 100644 --- a/db/routines/util/functions/binlogQueue_getDelay.sql +++ b/db/routines/util/functions/binlogQueue_getDelay.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255)) RETURNS BIGINT + READS SQL DATA NOT DETERMINISTIC BEGIN /** diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index e20244648..41105fe23 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; - DECLARE cCur CURSOR FOR + DECLARE cTickets CURSOR FOR SELECT id FROM ticket WHERE refFk IS NULL AND ((vScope = 'client' AND clientFk = vId) @@ -22,11 +22,11 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cCur; + OPEN cTickets; myLoop: LOOP SET vDone = FALSE; - FETCH cCur INTO vTicketFk; + FETCH cTickets INTO vTicketFk; IF vDone THEN LEAVE myLoop; @@ -35,6 +35,6 @@ BEGIN CALL ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cCur; + CLOSE cTickets; END$$ DELIMITER ; From a1a3470df4754db3cd6ece40849827b00e8d810d Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 22 Apr 2024 09:43:13 +0200 Subject: [PATCH 58/78] feat: refs #174903 --- db/routines/vn/procedures/item_getSimilar.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index f7126c1a5..e576a6c16 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -66,8 +66,7 @@ BEGIN ELSE 1 END AS minQuantity, iss.visible located, - b.price2, - b.price3 + b.price2 FROM vn.item i JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalcFk From b88dff0d997e66e1ad6295a23d7a3eb01b426141 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 22 Apr 2024 10:48:37 +0200 Subject: [PATCH 59/78] feat: refs #6777 --- db/routines/vn/functions/getAlert3StateTest.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index beba0948c..f1a8ac4cc 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -13,7 +13,7 @@ BEGIN INTO vDeliveryType FROM ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk - WHERE id = vTicket; + WHERE t.id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS From eb9f81c81d94ab6bd91d18c289607cf1dd18cc7f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Apr 2024 13:05:16 +0200 Subject: [PATCH 60/78] feat #7181 Rollback creditInsurance_getRisk --- .../vn/procedures/creditInsurance_getRisk.sql | 42 +++++++++++++++++++ .../10990-yellowPalmetto/00-firstScript.sql | 8 +++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/procedures/creditInsurance_getRisk.sql diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql new file mode 100644 index 000000000..8ddb9d721 --- /dev/null +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -0,0 +1,42 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +BEGIN +/** +* Devuelve el riesgo de los clientes que estan asegurados +*/ + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT cc.client clientFk, ci.grade + FROM creditClassification cc + JOIN creditInsurance ci ON cc.id = ci.creditClassification + WHERE dateEnd IS NULL + ORDER BY ci.creationDate DESC + LIMIT 10000000000000000000) t1 + GROUP BY clientFk; + + CALL client_getDebt(util.VN_CURDATE()); + + SELECT c.id, + c.name, + c.credit clientCredit, + c.creditInsurance solunion, + CAST(r.risk AS DECIMAL(10,0)) risk, + CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive, + cac.invoiced billedAnnually, + c.dueDay, + cgd.grade, + c2.country + FROM tmp.clientGetDebt cgd + LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk + JOIN client c ON c.id = cgd.clientFk + JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk + JOIN country c2 ON c2.id = c.countryFk + GROUP BY c.id; + + DROP TEMPORARY TABLE + tmp.risk, + tmp.clientGetDebt; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql index be866af8c..56b1541fb 100644 --- a/db/versions/10990-yellowPalmetto/00-firstScript.sql +++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql @@ -2,4 +2,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`() BEGIN END; -GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss; +GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financial; + +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +BEGIN +END; + +GRANT EXECUTE ON PROCEDURE vn.creditInsurance_getRisk TO financial; From d249645c370821d09c5561c8cff35de2faef3215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Apr 2024 17:51:21 +0200 Subject: [PATCH 61/78] Hot fix informe facturas recibidas Ticket #176640 --- .../reports/invoice/sql/rectified.sql | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/print/templates/reports/invoice/sql/rectified.sql b/print/templates/reports/invoice/sql/rectified.sql index 79ce733e3..48eefb093 100644 --- a/print/templates/reports/invoice/sql/rectified.sql +++ b/print/templates/reports/invoice/sql/rectified.sql @@ -1,11 +1,9 @@ -SELECT - io2.amount, - io2.ref, - io2.issued, - ict.description -FROM invoiceOut io - JOIN invoiceCorrection ic ON ic.correctingFk = io.id - JOIN invoiceOut io2 ON io2.id = ic.correctedFk - LEFT JOIN ticket t ON t.refFk = io.ref - JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk -WHERE io.ref = ? +SELECT io2.amount, + io2.ref, + io2.issued, + ict.description + FROM invoiceOut io + JOIN invoiceCorrection ic ON ic.correctingFk = io.id + JOIN invoiceOut io2 ON io2.id = ic.correctedFk + JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk + WHERE io.ref = ? From 9899efab97745c98f796ca9eab872c75928afe60 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 22 Apr 2024 17:55:49 +0200 Subject: [PATCH 62/78] refs #7032 Delete vn.recipe_Cook --- db/routines/vn/procedures/recipe_Cook.sql | 74 ----------------------- 1 file changed, 74 deletions(-) delete mode 100644 db/routines/vn/procedures/recipe_Cook.sql diff --git a/db/routines/vn/procedures/recipe_Cook.sql b/db/routines/vn/procedures/recipe_Cook.sql deleted file mode 100644 index 9371ef820..000000000 --- a/db/routines/vn/procedures/recipe_Cook.sql +++ /dev/null @@ -1,74 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`recipe_Cook`(vItemFk INT, vBunchesQuantity INT, vDate DATE) -BEGIN - - DECLARE vCalc INT; - DECLARE vWarehouseFk INT DEFAULT 1; -- Silla FV - - SET @element := ''; - SET @counter := 0; - - CALL cache.available_refresh(vCalc, FALSE, vWarehouseFk, vDate); - - DROP TEMPORARY TABLE IF EXISTS tmp.recipeCook; - - CREATE TEMPORARY TABLE tmp.recipeCook - SELECT *, - @counter := IF(@element = element COLLATE utf8_general_ci , @counter + 1, 1) as counter, - @element := element COLLATE utf8_general_ci - FROM - ( - SELECT i.id itemFk, - CONCAT(i.longName, ' (ref: ',i.id,')') longName, - i.size, - i.inkFk, - a.available, - r.element, - vBunchesQuantity * r.quantity as quantity, - r.itemFk as bunchItemFk, - IFNULL((i.inkFk = r.inkFk ) ,0) - + IFNULL((i.size = r.size) ,0) - + IFNULL((i.name LIKE CONCAT('%',r.name,'%')) ,0) - + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0) - + IFNULL((i.typeFk = r.typeFk),0) as matches, - i.typeFk, - rl.previousSelected - FROM vn.recipe r - JOIN vn.item i ON (IFNULL(i.name LIKE CONCAT('%',r.name,'%'), 0) - OR IFNULL(i.longName LIKE CONCAT('%',r.longName,'%'),0)) - OR i.typeFk <=> r.typeFk - JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalc - LEFT JOIN (SELECT recipe_ItemFk, element as log_element, selected_ItemFk, count(*) as previousSelected - FROM vn.recipe_log - GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk - AND rl.log_element = r.element - AND rl.selected_ItemFk = i.id - WHERE r.itemFk = vItemFk - AND a.available > vBunchesQuantity * r.quantity - UNION ALL - SELECT 100 itemFk, - CONCAT('? ',r.element,' ',IFNULL(r.size,''),' ',IFNULL(r.inkFk,'')) as longName, - NULL, - NULL, - 0, - r.element, - vBunchesQuantity * r.quantity as quantity, - r.itemFk as bunchItemFk, - -1 as matches, - r.typeFk, - NULL - FROM vn.recipe r - WHERE r.itemFk = vItemFk - GROUP BY r.element - ) sub - - ORDER BY element, matches DESC, previousSelected DESC; - - SELECT * - FROM tmp.recipeCook - WHERE counter < 6 - OR itemFk = 100 - ; - -END$$ -DELIMITER ; From 8bb331f0ed034f0e20eb9e8c2381db6a211d8598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Apr 2024 19:57:17 +0200 Subject: [PATCH 63/78] =?UTF-8?q?feat:=20Varias=20l=C3=ADneas=20farming=20?= =?UTF-8?q?en=20albaranes=20refs=20#7020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/versions/11007-greenRose/00-firstScript.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/versions/11007-greenRose/00-firstScript.sql diff --git a/db/versions/11007-greenRose/00-firstScript.sql b/db/versions/11007-greenRose/00-firstScript.sql new file mode 100644 index 000000000..69959f0b4 --- /dev/null +++ b/db/versions/11007-greenRose/00-firstScript.sql @@ -0,0 +1,12 @@ + +CREATE OR REPLACE TABLE `vn`.`farmingDeliveryNote` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `farmingFk` int(10) unsigned NOT NULL, + `deliveryNoteFk` int(11) NOT NULL, + `amount` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `farmingDeliveryNoteFk_FK` (`deliveryNoteFk`), + KEY `farmingDeliveryNoteFk_FK_1` (`farmingFk`), + CONSTRAINT `farmingDeliveryNoteFk_FK` FOREIGN KEY (`deliveryNoteFk`) REFERENCES `deliveryNote` (`id`), + CONSTRAINT `farmingDeliveryNoteFk_FK_1` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`) +); From 85491613b0d536f1562ad3accdcb0b75982164b9 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 08:47:28 +0200 Subject: [PATCH 64/78] test: refs #7173 fix fixtures --- db/dump/fixtures.before.sql | 2 +- .../invoiceIn/back/methods/invoice-in/specs/filter.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 219686fac..ff58af2e2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2617,7 +2617,7 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo UPDATE `vn`.`invoiceIn` SET isBooked = TRUE - WHERE id IN (2, 5, 7, 8, 9, 10); + WHERE id IN (5, 7, 8, 9, 10); DELIMITER $$ CREATE PROCEDURE `tmp`.`ticket_recalc`() diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 3ff5a92f3..ff2164783 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(4); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { @@ -180,7 +180,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(5); expect(result[0].isBooked).toBeTruthy(); await tx.rollback(); From 60d5b9e4aaa5c64354740fe8fd68deeb30173d49 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 08:47:52 +0200 Subject: [PATCH 65/78] test: refs #7173 fix sql, adding alias --- .../route/back/methods/route/getTickets.js | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 2393018cf..0e7c9fe20 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -33,54 +33,54 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT - t.id, - t.packages, - t.warehouseFk, - t.nickname, - t.clientFk, - t.priority, - t.addressFk, - st.code ticketStateCode, - st.name ticketStateName, - wh.name warehouseName, - tob.description observationDelivery, - tob2.description observationDropOff, - tob2.id, - a.street, - a.postalCode, - a.city, - am.name agencyModeName, - u.nickname userNickname, - vn.ticketTotalVolume(t.id) volume, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, - c.phone clientPhone, - c.mobile clientMobile, - a.phone addressPhone, - a.mobile addressMobile, - a.longitude, - a.latitude, - wm.mediaValue salePersonPhone, - t.cmrFk, - t.isSigned signed - FROM vn.route r - JOIN ticket t ON t.routeFk = r.id - JOIN client c ON t.clientFk = c.id - LEFT JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN warehouse wh ON wh.id = t.warehouseFk - LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = ot.id - LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' - LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id - AND tob2.observationTypeFk = ot2.id - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN account.user u ON u.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` + t.id, + t.packages, + t.warehouseFk, + t.nickname, + t.clientFk, + t.priority, + t.addressFk, + st.code ticketStateCode, + st.name ticketStateName, + wh.name warehouseName, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id observationId, + a.street, + a.postalCode, + a.city, + am.name agencyModeName, + u.nickname userNickname, + vn.ticketTotalVolume(t.id) volume, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + c.phone clientPhone, + c.mobile clientMobile, + a.phone addressPhone, + a.mobile addressMobile, + a.longitude, + a.latitude, + wm.mediaValue salePersonPhone, + t.cmrFk, + t.isSigned signed + FROM vn.route r + JOIN ticket t ON t.routeFk = r.id + JOIN client c ON t.clientFk = c.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN observationType ot ON ot.code = 'delivery' + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN account.user u ON u.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` ); if (!filter.where) filter.where = {}; From 06e743f5daea979efe0deec892c53d94fb36299b Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 23 Apr 2024 10:00:11 +0200 Subject: [PATCH 66/78] fix: refs #7253 check booked add new restriction to be tested --- e2e/paths/12-entry/05_basicData.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/12-entry/05_basicData.spec.js b/e2e/paths/12-entry/05_basicData.spec.js index 15282820e..f1f14f8da 100644 --- a/e2e/paths/12-entry/05_basicData.spec.js +++ b/e2e/paths/12-entry/05_basicData.spec.js @@ -76,6 +76,6 @@ describe('Entry basic data path', () => { expect(confirmed).toBe('checked'); expect(inventory).toBe('checked'); expect(raid).toBe('checked'); - expect(booked).toBe('checked'); + expect(booked).toBe('unchecked'); }); }); From 7fd7acbb568491a0e63d789ba7c76d1eb7d33ccf Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 10:06:22 +0200 Subject: [PATCH 67/78] deploy: refs #7253 init version 2420 --- CHANGELOG.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2be92faa..1b938797e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [24.18.01] - 2024-05-02 +## [24.20.01] - 2024-05-14 + +## [24.18.01] - 2024-05-07 ## [24.16.01] - 2024-04-18 diff --git a/package.json b/package.json index aa2aa2238..033eafc40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.18.0", + "version": "24.20.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 6f0038e4cc263add05b6c513f382ab3fc438551e Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 10:23:21 +0200 Subject: [PATCH 68/78] fix: refs #7226 disable debug --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bfe31fc60..9d5954f86 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ node { FROM_GIT = env.JOB_NAME.startsWith('gitea/') RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT RUN_BUILD = PROTECTED_BRANCH && FROM_GIT - env.DEBUG = 'strong-remoting:shared-method' + // env.DEBUG = 'strong-remoting:shared-method' // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" From 8dd4ac91199916ac5c45f94f600087974a65338c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Apr 2024 11:50:48 +0200 Subject: [PATCH 69/78] hotfix: Throw msg and entry_updateComission start transaction --- db/routines/vn/procedures/buy_chekItem.sql | 6 +++--- db/routines/vn/procedures/entry_updateComission.sql | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/buy_chekItem.sql b/db/routines/vn/procedures/buy_chekItem.sql index 0a0f00345..e8cf05fed 100644 --- a/db/routines/vn/procedures/buy_chekItem.sql +++ b/db/routines/vn/procedures/buy_chekItem.sql @@ -19,10 +19,10 @@ BEGIN AND a.hasWeightVolumetric LIMIT 1; - DROP TEMPORARY TABLE IF EXISTS tmp.buysToCheck; + DROP TEMPORARY TABLE tmp.buysToCheck; - IF hasVolumetricAgency THEN - CALL util.throw('Some purchase line has an item without size or weight per stem in the volumetric agency.'); + IF hasVolumetricAgency THEN + CALL util.throw('Item lacks size/weight in purchase line at agency'); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/entry_updateComission.sql b/db/routines/vn/procedures/entry_updateComission.sql index 1bef79bd3..ceed20d78 100644 --- a/db/routines/vn/procedures/entry_updateComission.sql +++ b/db/routines/vn/procedures/entry_updateComission.sql @@ -9,6 +9,14 @@ BEGIN DECLARE vCurrencyName VARCHAR(25); DECLARE vComission INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + CREATE OR REPLACE TEMPORARY TABLE tmp.recalcEntryCommision SELECT e.id FROM vn.entry e @@ -28,12 +36,15 @@ BEGIN WHERE id = vCurrency; CALL entry_recalc(); + + COMMIT; + SELECT util.notification_send( 'entry-update-comission', JSON_OBJECT('currencyName', vCurrencyName, 'referenceCurrent', vComission), NULL ); - DROP TEMPORARY TABLE tmp.recalcEntryCommision; + DROP TEMPORARY TABLE tmp.recalcEntryCommision; END$$ DELIMITER ; From d1c72a0be3fbd83b915d67469dee00452922fa09 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 23 Apr 2024 14:05:48 +0200 Subject: [PATCH 70/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/available_traslate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 9934c1c44..513df98aa 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -25,7 +25,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios. SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); + SET vDatedTo = TIMESTAMP(vDated + INTERVAL 4 DAY, '23:59:59'); SELECT inventoried INTO vDatedInventory FROM config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; From 0fd120676db1306b1754102bf6e0ff9650b06db5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 23 Apr 2024 12:29:40 +0000 Subject: [PATCH 71/78] Actualizar modules/ticket/back/methods/ticket-request/filter.js --- modules/ticket/back/methods/ticket-request/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 10aaf02e5..5364cef9a 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -135,7 +134,8 @@ module.exports = Self => { tr.requesterFk, tr.isOk, s.quantity saleQuantity, - s.itemFk, + s.itemFk saleItemFk, + i.id itemFk, i.name itemDescription, t.shipped, DATE(t.shipped) shippedDate, From ec23cc7619ff59c1a4c981c1831ffdaef15d2708 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Apr 2024 14:41:43 +0200 Subject: [PATCH 72/78] hotfix: entry_checkBooked --- db/routines/vn/procedures/entry_checkBooked.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/entry_checkBooked.sql b/db/routines/vn/procedures/entry_checkBooked.sql index 3ca8c9642..7ee1fee22 100644 --- a/db/routines/vn/procedures/entry_checkBooked.sql +++ b/db/routines/vn/procedures/entry_checkBooked.sql @@ -15,7 +15,7 @@ BEGIN FROM `entry` WHERE id = vSelf; - IF vIsBooked AND NOT @isModeInventory THEN + IF vIsBooked AND NOT IFNULL(@isModeInventory, FALSE) THEN CALL util.throw('Entry is already booked'); END IF; END$$ From 5efb6acafeab31a146eac5412e38aafb460bba6c Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 23 Apr 2024 14:55:05 +0200 Subject: [PATCH 73/78] feat: refs#6493 Cambios solicitados procedimientos --- db/routines/vn/procedures/available_traslate.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 513df98aa..d33a8e10e 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -24,8 +24,8 @@ proc: BEGIN CALL item_getStock (vWarehouseLanding, vDated, NULL); -- Calcula algunos parámetros necesarios. - SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); - SET vDatedTo = TIMESTAMP(vDated + INTERVAL 4 DAY, '23:59:59'); + SET vDatedFrom = vDated; + SET vDatedTo = util.dayEnd (vDated + INTERVAL 4 DAY); SELECT inventoried INTO vDatedInventory FROM config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; From cc06698214cc92b3d31263e721cf244f83401e9a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 15:37:04 +0200 Subject: [PATCH 74/78] hotFix(ticket): refs #7225 fix advanced and movable --- .../vn/procedures/ticket_canAdvance.sql | 48 ++++++------------- .../vn/procedures/ticket_getMovable.sql | 2 +- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 8852a3010..ab6a27364 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -8,38 +8,14 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ - DECLARE vDateInventory DATE; - SELECT inventoried INTO vDateInventory FROM config; - - CREATE OR REPLACE TEMPORARY TABLE tmp.stock - (itemFk INT PRIMARY KEY, - amount INT) - ENGINE = MEMORY; - - INSERT INTO tmp.stock(itemFk, amount) - SELECT itemFk, SUM(quantity) amount FROM - ( - SELECT itemFk, quantity - FROM itemTicketOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE landed >= vDateInventory - AND landed <= vDateToAdvance - AND isVirtualStock = FALSE - AND warehouseInFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseOutFk = vWarehouseFk - ) t - GROUP BY itemFk HAVING amount != 0; + CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL); + CALL item_getMinacum( + vWarehouseFk, + vDateToAdvance, + DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance), + NULL + ); CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) @@ -87,7 +63,7 @@ BEGIN count(s.id) futureLines, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM((s.quantity <= IFNULL(st.amount,0))) hasStock, + SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, z.id futureZoneFk, z.name futureZoneName, st.classColor, @@ -107,7 +83,9 @@ BEGIN JOIN agencyMode am ON t.agencyModeFk = am.id JOIN zone z ON t.zoneFk = z.id LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.stock st ON st.itemFk = i.id + LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id + AND im.warehouseFk = vWarehouseFk + LEFT JOIN tmp.itemList il ON il.itemFk = i.id WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id @@ -146,6 +124,8 @@ BEGIN ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; - DROP TEMPORARY TABLE tmp.stock; + DROP TEMPORARY TABLE IF EXISTS + tmp.itemList, + tmp.itemMinacum; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_getMovable.sql b/db/routines/vn/procedures/ticket_getMovable.sql index eee165538..d7bcf517b 100644 --- a/db/routines/vn/procedures/ticket_getMovable.sql +++ b/db/routines/vn/procedures/ticket_getMovable.sql @@ -21,7 +21,7 @@ BEGIN WHERE t.id = vTicketFk; -- Añadimos un dia más para calcular el stock hasta vNewShipped inclusive - CALL item_getStock(vWarehouseFk, DATE_ADD(vNewShipped, INTERVAL 1 DAY), NULL); + CALL item_getStock(vWarehouseFk, vNewShipped, NULL); CALL item_getMinacum( vWarehouseFk, vNewShipped, From 033bcf6b679f272d4dbe4232f03d7bbb2f083d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 23 Apr 2024 17:24:47 +0200 Subject: [PATCH 75/78] hotfix importErrorNotification refs #6189 --- db/routines/sage/procedures/importErrorNotification.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/sage/procedures/importErrorNotification.sql b/db/routines/sage/procedures/importErrorNotification.sql index b070097f4..75b0cffc8 100644 --- a/db/routines/sage/procedures/importErrorNotification.sql +++ b/db/routines/sage/procedures/importErrorNotification.sql @@ -43,7 +43,7 @@ BEGIN WHERE sub.amountTaxableBase<>sub2.amountTaxableBase AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase UNION ALL - SELECT CONCAT('- Factura Duplicada: ', mc.Asiento) + SELECT CONCAT('- Factura Duplicada: ', accountingEntryFk) FROM accountingEntryError )sub; From 0cd740ce0ca79e70ca1132a94564471a342ca44e Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Apr 2024 10:42:50 +0200 Subject: [PATCH 76/78] test: refs #7225 fix back test --- modules/ticket/back/methods/ticket/priceDifference.js | 4 ++-- .../back/methods/ticket/specs/priceDifference.spec.js | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 7dc85bd3d..7db03e268 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -118,7 +118,7 @@ module.exports = Self => { const [salesMovable] = await Self.rawSql(query, params, myOptions); const itemMovable = new Map(); - for (sale of salesMovable) { + for (let sale of salesMovable) { const saleMovable = sale.movable ? sale.movable : 0; itemMovable.set(sale.id, saleMovable); } @@ -129,7 +129,7 @@ module.exports = Self => { const [difComponents] = await Self.rawSql(query, params, myOptions); const map = new Map(); - for (difComponent of difComponents) + for (let difComponent of difComponents) map.set(difComponent.saleFk, difComponent); for (sale of salesObj.items) { diff --git a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js index d01f0c1bb..e5c06b6dd 100644 --- a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js +++ b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const UserError = require('vn-loopback/util/user-error'); const ForbiddenError = require('vn-loopback/util/forbiddenError'); describe('sale priceDifference()', () => { @@ -83,12 +82,10 @@ describe('sale priceDifference()', () => { warehouseId: 1 }; - const result = await models.Ticket.priceDifference(ctx, options); - const firstItem = result.items[0]; - const secondtItem = result.items[1]; + const {items} = await models.Ticket.priceDifference(ctx, options); - expect(firstItem.movable).toEqual(380); - expect(secondtItem.movable).toEqual(1790); + expect(items[0].movable).toEqual(410); + expect(items[1].movable).toEqual(1810); await tx.rollback(); } catch (e) { From eced03f69bc10fdca1deeced089fa7de82cc33d8 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Apr 2024 11:40:24 +0200 Subject: [PATCH 77/78] fix(ticket_getMovable): refs #7225 stock add ifnull --- db/routines/vn/procedures/ticket_canAdvance.sql | 6 +++--- db/routines/vn/procedures/ticket_getMovable.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index ab6a27364..d1ca7b5e2 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -124,8 +124,8 @@ BEGIN ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; - DROP TEMPORARY TABLE IF EXISTS - tmp.itemList, - tmp.itemMinacum; + DROP TEMPORARY TABLE IF EXISTS + tmp.itemList, + tmp.itemMinacum; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_getMovable.sql b/db/routines/vn/procedures/ticket_getMovable.sql index d7bcf517b..512151bd4 100644 --- a/db/routines/vn/procedures/ticket_getMovable.sql +++ b/db/routines/vn/procedures/ticket_getMovable.sql @@ -38,7 +38,7 @@ BEGIN s.discount, i.image, i.subName, - il.stock + IFNULL(im.amount, 0) AS movable + IFNULL(il.stock,0) + IFNULL(im.amount, 0) AS movable FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk @@ -48,8 +48,8 @@ BEGIN WHERE t.id = vTicketFk; DROP TEMPORARY TABLE IF EXISTS - tmp.itemList, - tmp.itemMinacum; + tmp.itemList, + tmp.itemMinacum; END$$ DELIMITER ; From 69486fb29f9d59cd1d9e6a72437077fcc1c87c9f Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Apr 2024 14:15:27 +0200 Subject: [PATCH 78/78] fix(componentUpdate): refs #7225 fix transfer all lines to newTicket --- modules/ticket/back/methods/ticket/componentUpdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 0786b72c8..8bea731b7 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -150,7 +150,7 @@ module.exports = Self => { const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity); const salesNewTicketLength = salesNewTicket.length; - if (salesNewTicketLength && sales.length != salesNewTicketLength) { + if (salesNewTicketLength && (args.newTicket || sales.length != salesNewTicketLength)) { const newTicket = await models.Ticket.transferSales( ctx, args.id,