From dc1ef34abacf790b0a4b6e49e465550775e12de7 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 31 Jan 2024 09:54:47 +0100 Subject: [PATCH 001/152] 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 002/152] 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 003/152] 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 004/152] 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 005/152] 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 006/152] 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 007/152] 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 008/152] 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 009/152] 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 010/152] 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 011/152] 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 9aad1dd6e843cfb20f3d7494937e1cebe4aae41a Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 5 Mar 2024 12:41:54 +0100 Subject: [PATCH 012/152] feat: refs #6500 procRefactor8 --- db/routines/vn/events/raidUpdate.sql | 8 ++++ db/routines/vn/procedures/creditRecovery.sql | 49 ++++++++++++++++++++ db/routines/vn/procedures/raidUpdate.sql | 30 ++++++++++++ db/routines/vn/procedures/rateView.sql | 42 +++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 db/routines/vn/events/raidUpdate.sql create mode 100644 db/routines/vn/procedures/creditRecovery.sql create mode 100644 db/routines/vn/procedures/raidUpdate.sql create mode 100644 db/routines/vn/procedures/rateView.sql diff --git a/db/routines/vn/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql new file mode 100644 index 000000000..619dadb48 --- /dev/null +++ b/db/routines/vn/events/raidUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`raidUpdate` + ON SCHEDULE EVERY 1 DAY + STARTS '2017-12-29 00:05:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL raidUpdate$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql new file mode 100644 index 000000000..5a32a87f8 --- /dev/null +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -0,0 +1,49 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() +BEGIN + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE `client` c + JOIN payMethod pm ON pm.id = c.payMethodFk + SET c.credit = 0 + WHERE pm.`code` = 'card'; + + DROP TEMPORARY TABLE IF EXISTS tCreditClients; + CREATE TEMPORARY TABLE tCreditClients + SELECT clientFk, IF (credit > recovery ,credit - recovery,0) newCredit + FROM ( + SELECT r.clientFk, + r.amount recovery, + timestampadd(DAY, r.period, sub2.created) deadLine, + sub2.amount credit + FROM recovery r + JOIN ( + SELECT clientFk, amount , created + FROM ( + SELECT * FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub + GROUP BY clientFk + ) sub2 ON sub2.clientFk = r.clientFk + WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() + GROUP BY r.clientFk + HAVING deadLine <= util.VN_CURDATE() + ) sub3 + WHERE credit > 0; + + UPDATE client c + JOIN tCreditClients cc ON cc.clientFk = c.clientFk + SET Clientes.Credito = newCredit; + + DROP TEMPORARY TABLE tCreditClients; + COMMIT; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql new file mode 100644 index 000000000..214974350 --- /dev/null +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() +BEGIN + + UPDATE entry e + JOIN entryVirtual ev ON ev.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN ( + SELECT * + FROM ( + SELECT id, landed, tt.warehouseInFk, tt.warehouseOutFk + FROM travel t + JOIN ( + SELECT t.warehouseInFk, t.warehouseOutFk + FROM entryVirtual ev + JOIN entry e ON e.id = ev.entryFk + JOIN travel t ON t.id = e.travelFk + GROUP BY t.warehouseInFk, t.warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + + WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE + ORDER BY t.landed + LIMIT 10000000000000000000 + ) t + GROUP BY warehouseInFk, warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + SET e.travelFk = t.id; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql new file mode 100644 index 000000000..6da1ea017 --- /dev/null +++ b/db/routines/vn/procedures/rateView.sql @@ -0,0 +1,42 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() +BEGIN + + DECLARE v10Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 10 YEAR; + + SELECT + t.year, + t.month, + pagos.dollars, + pagos.changePractical, + CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, + pagos.changeOfficial + FROM invoiceIn ii + JOIN time t ON t.dated = ii.issued + JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk + JOIN + ( + SELECT + t.year, + t.month, + CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial + FROM payment p + JOIN time t ON t.dated = p.received + JOIN referenceRate rr ON rr.dated = p.received + JOIN currency c ON c.id = rr.currencyFk + WHERE divisa + AND p.received >= v10Years + AND c.code = 'USD' + GROUP BY t.year, t.month + ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH + JOIN currency c ON c.id = ii.currencyFk + WHERE c.code = 'USD' + AND ii.issued >= v10Years + AND iit.foreignValue + AND iit.taxableBase + GROUP BY t.year, t.month; + +END$$ +DELIMITER ; From e83b0622cfb893c8294a042ee7dc37e0211a4b96 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 5 Mar 2024 13:21:53 +0100 Subject: [PATCH 013/152] refs 6500 rateView --- db/routines/vn/procedures/rateView.sql | 34 +++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 6da1ea017..fb03c192a 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -2,9 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() BEGIN - DECLARE v10Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 10 YEAR; - - SELECT + SELECT t.year, t.month, pagos.dollars, @@ -15,28 +13,24 @@ BEGIN JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk JOIN - ( - SELECT - t.year, - t.month, - CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, - CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, - CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial - FROM payment p - JOIN time t ON t.dated = p.received - JOIN referenceRate rr ON rr.dated = p.received - JOIN currency c ON c.id = rr.currencyFk - WHERE divisa - AND p.received >= v10Years - AND c.code = 'USD' - GROUP BY t.year, t.month + ( SELECT + t.year, + t.month, + CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial + FROM payment p + JOIN time t ON t.dated = p.received + JOIN referenceRate rr ON rr.dated = p.received + JOIN currency c ON c.id = rr.currencyFk + WHERE divisa + AND c.code = 'USD' + GROUP BY t.year, t.month ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH JOIN currency c ON c.id = ii.currencyFk WHERE c.code = 'USD' - AND ii.issued >= v10Years AND iit.foreignValue AND iit.taxableBase GROUP BY t.year, t.month; - END$$ DELIMITER ; From 2f0c1612c2770fd300090e45fe84ff7446c911e7 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 6 Mar 2024 12:02:34 +0100 Subject: [PATCH 014/152] feat: refs #6500 delete procedure --- db/routines/vn/procedures/riskAllClients.sql | 24 +++--- .../vn/procedures/solunionRiskRequest.sql | 16 ++-- db/routines/vn2008/events/raidUpdate.sql | 8 -- db/routines/vn2008/procedures/raidUpdate.sql | 28 ------- db/routines/vn2008/procedures/rateView.sql | 37 -------- .../vn2008/procedures/recobro_credito.sql | 45 ---------- .../vn2008/procedures/risk_vs_client_list.sql | 84 ------------------- 7 files changed, 20 insertions(+), 222 deletions(-) delete mode 100644 db/routines/vn2008/events/raidUpdate.sql delete mode 100644 db/routines/vn2008/procedures/raidUpdate.sql delete mode 100644 db/routines/vn2008/procedures/rateView.sql delete mode 100644 db/routines/vn2008/procedures/recobro_credito.sql delete mode 100644 db/routines/vn2008/procedures/risk_vs_client_list.sql diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 66c0a0dd5..621d047ae 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -3,27 +3,27 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(max BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + CREATE TEMPORARY TABLE tmp.client_list + (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY SELECT id Id_Cliente, null grade FROM vn.client; - - CALL vn2008.risk_vs_client_list(maxRiskDate); - + + CALL client_getDebt (maxRiskDate); + SELECT c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais FROM vn2008.Clientes c JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente GROUP BY c.Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/solunionRiskRequest.sql b/db/routines/vn/procedures/solunionRiskRequest.sql index b735bea33..7a7102782 100644 --- a/db/routines/vn/procedures/solunionRiskRequest.sql +++ b/db/routines/vn/procedures/solunionRiskRequest.sql @@ -8,15 +8,15 @@ BEGIN ENGINE = MEMORY SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification - WHERE dateEnd IS NULL - ORDER BY ci.creationDate DESC + WHERE dateEnd IS NULL + ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente; - - CALL vn2008.risk_vs_client_list(util.VN_CURDATE()); - + + CALL client_getDebt (util.VN_CURDATE()); + SELECT c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo, - cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo, + cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo, f.Consumo consumo_anual, c.Vencimiento, ci.grade FROM vn2008.Clientes c @@ -24,8 +24,8 @@ BEGIN JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente GROUP BY Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn2008/events/raidUpdate.sql b/db/routines/vn2008/events/raidUpdate.sql deleted file mode 100644 index aacfd6dcd..000000000 --- a/db/routines/vn2008/events/raidUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn2008`.`raidUpdate` - ON SCHEDULE EVERY 1 DAY - STARTS '2017-12-29 00:05:00.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL raidUpdate$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/raidUpdate.sql b/db/routines/vn2008/procedures/raidUpdate.sql deleted file mode 100644 index 9746f3cf9..000000000 --- a/db/routines/vn2008/procedures/raidUpdate.sql +++ /dev/null @@ -1,28 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`raidUpdate`() -BEGIN - - UPDATE Entradas e - JOIN Entradas_Auto ea USING (Id_Entrada) - JOIN travel t ON t.id = e.travel_id - JOIN ( - SELECT * - FROM ( - SELECT id, landing, warehouse_id, warehouse_id_out - FROM travel - JOIN ( - SELECT warehouse_id, warehouse_id_out - FROM Entradas_Auto ea - JOIN Entradas e USING(Id_Entrada) - JOIN travel t ON t.id = e.travel_id - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - WHERE shipment > util.VN_CURDATE() AND delivered = FALSE - ORDER BY landing - LIMIT 10000000000000000000 - ) t - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - SET e.travel_id = t.id; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/rateView.sql b/db/routines/vn2008/procedures/rateView.sql deleted file mode 100644 index 91e317be6..000000000 --- a/db/routines/vn2008/procedures/rateView.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`rateView`() -BEGIN - - SELECT - t.year as año, - t.month as mes, - pagos.dolares, - pagos.cambioPractico, - CAST(sum(divisa) / sum(bi) as DECIMAL(5,4)) as cambioTeorico, - pagos.cambioOficial - FROM recibida r - JOIN time t ON t.date = r.fecha - JOIN recibida_iva ri ON r.id = ri.recibida_id - JOIN - ( - SELECT - t.year as Año, - t.month as Mes, - cast(sum(divisa) as DECIMAL(10,2)) as dolares, - cast(sum(divisa) / sum(importe) as DECIMAL(5,4)) as cambioPractico, - cast(rr.rate * 0.998 as DECIMAL(5,4)) as cambioOficial - FROM pago p - JOIN time t ON t.date = p.fecha - JOIN reference_rate rr ON rr.date = p.fecha AND moneda_id = 2 - WHERE divisa - AND fecha >= '2015-01-11' - GROUP BY t.year, t.month - ) pagos ON t.year = pagos.Año AND t.month = pagos.Mes - WHERE moneda_id = 2 - AND fecha >= '2015-01-01' - AND divisa - AND bi - GROUP BY t.year, t.month; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql deleted file mode 100644 index 3657f2b9b..000000000 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recobro_credito`() -BEGIN - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - UPDATE vn.`client` c - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - SET credit = 0 - WHERE pm.`code` = 'card'; - - DROP TEMPORARY TABLE IF EXISTS clientes_credit; - CREATE TEMPORARY TABLE clientes_credit - SELECT Id_Cliente, if (Credito > Recobro ,Credito - Recobro,0) AS newCredit - FROM ( - SELECT r.Id_Cliente, r.amount AS Recobro, - timestampadd(DAY, period, UltimaFecha) AS Deadline, sub2.amount AS Credito - FROM vn2008.recovery r - JOIN ( - SELECT Id_Cliente, amount , odbc_date AS UltimaFecha - FROM ( - SELECT * FROM credit - ORDER BY odbc_date DESC - LIMIT 10000000000000000000 - ) sub - GROUP BY Id_Cliente - ) sub2 USING(Id_Cliente) - WHERE dend IS NULL or dend >= util.VN_CURDATE() - GROUP BY Id_Cliente - HAVING Deadline <= util.VN_CURDATE() - ) sub3 - WHERE Credito > 0; - - UPDATE Clientes - JOIN clientes_credit USING(Id_Cliente) - SET Clientes.Credito = newCredit; - - DROP TEMPORARY TABLE clientes_credit; - COMMIT; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql deleted file mode 100644 index 92f94eb9f..000000000 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ /dev/null @@ -1,84 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE) -BEGIN -/** - * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list - * - * @deprecated usar vn.client_getDebt - * @param maxRiskDate Fecha maxima de los registros - * @return table tmp.risk - */ - DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE()); - DECLARE endingDate DATETIME; - DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; - - SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE()); - SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2; - CREATE TEMPORARY TABLE tmp.client_list_2 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3; - CREATE TEMPORARY TABLE tmp.client_list_3 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar; - 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 - 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 - WHERE Factura IS NULL - AND Fecha BETWEEN startingDate AND endingDate - GROUP BY t.Id_Cliente; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - CREATE TEMPORARY TABLE tmp.risk - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo - FROM Clientes c - JOIN ( - SELECT clientFk, SUM(amount) amount,SUM(amount) saldo - FROM vn.clientRisk - JOIN tmp.client_list on Id_Cliente = clientFk - GROUP BY clientFk - UNION ALL - SELECT Id_Cliente, SUM(Entregado),SUM(Entregado) - FROM Recibos - JOIN tmp.client_list_2 using(Id_Cliente) - WHERE Fechacobro > endingDate - GROUP BY Id_Cliente - UNION ALL - SELECT Id_Cliente, total,0 - FROM tmp.tickets_sin_facturar - UNION ALL - SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction t - JOIN tmp.client_list_3 on Id_Cliente = t.clientFk - WHERE t.receiptFk IS NULL - AND t.status = 'ok' - GROUP BY t.clientFk - ) t ON c.Id_Cliente = t.clientFk - WHERE c.activo != FALSE - GROUP BY c.Id_Cliente; - - DELETE r.* - FROM tmp.risk r - JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente - JOIN vn2008.pay_met pm on pm.id = c.pay_met_id - WHERE IFNULL(r.saldo,0) < 10 - AND r.risk <= MAX_RISK_ALLOWED - AND pm.`name` = 'TARJETA'; -END$$ -DELIMITER ; From 194947dc9a0cf3dccd0bb9ed69acd357e6fb41a4 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 6 Mar 2024 14:11:07 +0100 Subject: [PATCH 015/152] feat: refs #6500 procRefactor8 --- db/routines/vn/procedures/client_getDebt.sql | 6 ++-- db/routines/vn/procedures/creditRecovery.sql | 2 +- db/routines/vn/procedures/riskAllClients.sql | 32 +++++++++---------- .../vn/procedures/solunionRiskRequest.sql | 25 ++++++++------- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/procedures/client_getDebt.sql b/db/routines/vn/procedures/client_getDebt.sql index ad7b5b7d2..3eaace4e9 100644 --- a/db/routines/vn/procedures/client_getDebt.sql +++ b/db/routines/vn/procedures/client_getDebt.sql @@ -17,15 +17,15 @@ BEGIN SET vEnded = util.dayEnd(IFNULL(vDate, util.VN_CURDATE())); - CREATE OR REPLACE TEMPORARY TABLE tClientRisk + CREATE OR REPLACE TEMPORARY TABLE tClientRisk ENGINE = MEMORY - SELECT cr.clientFk, SUM(cr.amount) amount + SELECT cr.clientFk, SUM(cr.amount) amount FROM clientRisk cr JOIN tmp.clientGetDebt c ON c.clientFk = cr.clientFk GROUP BY cr.clientFk; INSERT INTO tClientRisk - SELECT c.clientFk, SUM(r.amountPaid) + SELECT c.clientFk, SUM(r.amountPaid) FROM receipt r JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk WHERE r.payed > vEnded diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index 5a32a87f8..e598661af 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -40,7 +40,7 @@ BEGIN UPDATE client c JOIN tCreditClients cc ON cc.clientFk = c.clientFk - SET Clientes.Credito = newCredit; + SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; COMMIT; diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 621d047ae..c818c715c 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -2,28 +2,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) ENGINE = MEMORY - SELECT id Id_Cliente, null grade FROM vn.client; + SELECT id clientFk, null grade FROM client; CALL client_getDebt (maxRiskDate); SELECT - c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais - FROM - vn2008.Clientes c - JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente - JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente - GROUP BY c.Id_cliente; + c.RazonSocial, + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais + FROM + vn2008.Clientes c + JOIN tmp.risk r ON r.clientFk = c.Id_Cliente + JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk + GROUP BY c.Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/solunionRiskRequest.sql b/db/routines/vn/procedures/solunionRiskRequest.sql index 7a7102782..f5af4d0ad 100644 --- a/db/routines/vn/procedures/solunionRiskRequest.sql +++ b/db/routines/vn/procedures/solunionRiskRequest.sql @@ -2,15 +2,18 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`solunionRiskRequest`() BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) ENGINE = MEMORY - SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc - JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification - WHERE dateEnd IS NULL - ORDER BY ci.creationDate DESC - LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente; + SELECT * + FROM (SELECT cc.client clientFk, ci.grade + FROM vn.creditClassification cc + JOIN vn.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()); @@ -20,12 +23,12 @@ BEGIN f.Consumo consumo_anual, c.Vencimiento, ci.grade FROM vn2008.Clientes c - JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente - JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente + JOIN tmp.risk r ON r.clientFk = c.Id_Cliente + JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente GROUP BY Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; END$$ DELIMITER ; From 45bcf8043f03cb4eea2a621abb5c59af38661e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 7 Mar 2024 19:03:57 +0100 Subject: [PATCH 016/152] feat: permissions to vn.entry.isBooked refs#6724 --- db/versions/10944-tealLaurel/00-firstScript.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 db/versions/10944-tealLaurel/00-firstScript.sql diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql new file mode 100644 index 000000000..d11bcb333 --- /dev/null +++ b/db/versions/10944-tealLaurel/00-firstScript.sql @@ -0,0 +1,10 @@ + + REVOKE UPDATE ON vn.entry FROM entryEditor; + GRANT UPDATE ON vn.entry TO administrative; + + GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable, + isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk, + currencyFk,companyFk, gestDocFk, invoiceInFk, isBlocked, loadPriority, + kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, + observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked + ) ON vn.entry TO entryEditor; From 052acdcc0874f36b2e5e1913eca080c243a75126 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 13 Mar 2024 13:20:14 +0100 Subject: [PATCH 017/152] 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 018/152] 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 019/152] 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 562dd4034f2a9311fb45afaed6954ca73d0d1fc4 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 27 Mar 2024 07:58:35 +0100 Subject: [PATCH 020/152] feat: #7130 added "served" field to RouteList table(Salix). --- modules/route/back/methods/route/filter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 7c2225dc9..5b13a9004 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -67,6 +67,12 @@ module.exports = Self => { type: 'string', description: 'The description filter', http: {source: 'query'} + }, + { + arg: 'isOk', + type: 'boolean', + description: 'The isOk filter', + http: {source: 'query'} } ], returns: { @@ -102,6 +108,8 @@ module.exports = Self => { case 'agencyModeFk': param = `r.${param}`; return {[param]: value}; + case 'isOk': + return {'r.isOk': value}; } }); From 46f60615bd9a78df72488252e70dda9e4bda0f0a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Thu, 28 Mar 2024 14:27:29 +0100 Subject: [PATCH 021/152] 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 a62e189e470a2cfa8f0ff3e5e032e1de4835525f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 28 Mar 2024 16:10:52 +0100 Subject: [PATCH 022/152] feat: refs #6724 hook added --- modules/entry/back/models/entry.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..9d5cd4e1f 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -46,4 +46,15 @@ module.exports = Self => { } } }); + + Self.observe('before delete', async function(ctx) { + let isBooked = ctx.instance && ctx.instance.isBooked; + + if (isBooked === undefined) { + const entryInstance = await Self.findById(ctx.where.id); + isBooked = entryInstance.isBooked; + } + + if (isBooked) throw new Error('Booked entry cannot be deleted'); + }); }; From 4389cd5d746bc4ec2548f6474b5da45b37a40854 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 2 Apr 2024 09:56:46 +0200 Subject: [PATCH 023/152] 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 52457b964230af1eac10f328785d6c1c48f4deb8 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 07:09:07 +0200 Subject: [PATCH 024/152] feat: sin concatenar en el nombre --- db/routines/vn/procedures/itemTrash.sql | 56 ------------------- .../vn/procedures/item_setVisibleDiscard.sql | 8 +-- 2 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql deleted file mode 100644 index bbb30b78a..000000000 --- a/db/routines/vn/procedures/itemTrash.sql +++ /dev/null @@ -1,56 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, - vIsTrash BOOLEAN) -BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; - DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - - SELECT t.id INTO vTicketFk - FROM ticket t - JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk - AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; - - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - util.VN_CURDATE(), - account.myUser_getId(), - FALSE, - vTicketFk); - END IF; - - INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, - vItemFk, - CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), - vQuantity - FROM item - WHERE id = vItemFk; - - UPDATE cache.visible - SET visible = visible - vQuantity - WHERE calc_id = vCalc - AND item_id = vItemFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1cc2a8871..c1792dbb9 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -23,11 +23,11 @@ BEGIN SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk FROM vn.ticket LIMIT 1; - - IF vAddressFk IS NULL THEN + + IF vAddressFk IS NULL THEN SELECT pc.shortageAddressFk INTO vAddressShortage FROM productionConfig pc ; - ELSE + ELSE SET vAddressShortage = vAddressFk; END IF; @@ -65,7 +65,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + longName, vQuantity FROM item WHERE id = vItemFk; From d71f3e0818e38a978a01ccb508ead3b409755cb1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 09:02:34 +0200 Subject: [PATCH 025/152] test --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index c1792dbb9..59ffa0f66 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -13,6 +13,7 @@ BEGIN * @param vQuantity a dar de alta/baja * @param vAddressFk id address */ + DECLARE vTicketFk INT; DECLARE vClientFk INT; DECLARE vDefaultCompanyFk INT; From bd661befb6b2c0cfa2f8c05f711cd59c18384fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 4 Apr 2024 15:04:23 +0200 Subject: [PATCH 026/152] feat: bloquear facturas recibidas contabilizadas refs #7173 --- .../vn/procedures/invoiceIn_checkBooked.sql | 22 +++++++++++++++++++ .../invoiceInCorrection_beforeDelete.sql | 8 +++++++ .../invoiceInCorrection_beforeUpdate.sql | 8 +++++++ .../triggers/invoiceInDueDay_beforeDelete.sql | 8 +++++++ .../triggers/invoiceInDueDay_beforeInsert.sql | 1 + .../invoiceInIntrastat_beforeDelete.sql | 8 +++++++ .../invoiceInIntrastat_beforeUpdatesql | 8 +++++++ .../vn/triggers/invoiceInTax_beforeDelete.sql | 8 +++++++ .../vn/triggers/invoiceInTax_beforeUpdate.sql | 2 ++ .../vn/triggers/invoiceIn_afterDelete.sql | 2 ++ .../vn/triggers/invoiceIn_beforeUpdate.sql | 2 ++ 11 files changed, 77 insertions(+) create mode 100644 db/routines/vn/procedures/invoiceIn_checkBooked.sql create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql create mode 100644 db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql create mode 100644 db/routines/vn/triggers/invoiceInTax_beforeDelete.sql diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql new file mode 100644 index 000000000..862870eb4 --- /dev/null +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( + vSelf INT +) +BEGIN +/** + * Comprueba si una factura recibida está contabilizada, + * y si lo está retorna un throw. + * + * @param vSelf Id invoiceIn + */ + DECLARE vIsBooked BOOL; + + SELECT isBooked INTO vIsBooked + FROM invoiceIn + WHERE id = vSelf; + + IF vIsBooked THEN + CALL util.throw('InvoiceIn is already booked'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql new file mode 100644 index 000000000..f4df48dcd --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeDelete` + BEFORE DELETE ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.correctingFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql new file mode 100644 index 000000000..bd324863b --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeUpdate` + BEFORE UPDATE ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.correctingFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql new file mode 100644 index 000000000..3b0f90d0d --- /dev/null +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeDelete` + BEFORE DELETE ON `invoiceInDueDay` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.id); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..c23ead0e4 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql new file mode 100644 index 000000000..412b091f4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeDelete` + BEFORE DELETE ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql new file mode 100644 index 000000000..649c9ef30 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeUpdate` + BEFORE UPDATE ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql new file mode 100644 index 000000000..a43f602b4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDelete` + BEFORE DELETE ON `invoiceInTax` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 30918b7c5..3e5ecf030 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); + IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); END IF; diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index c088f6492..90fac193d 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN + CALL invoiceIn_checkBooked(OLD.id); + INSERT INTO invoiceInLog SET `action` = 'delete', `changedModel` = 'InvoiceIn', diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 4503c7dbd..688a3af92 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN DECLARE vWithholdingSageFk INT; + CALL invoiceIn_checkBooked(OLD.id); + IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN CALL util.throw('The invoiceIn reference contains invalid characters'); END IF; From d18721f50d23534c366b8b79aee8f5d1e441ca66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 4 Apr 2024 18:05:45 +0200 Subject: [PATCH 027/152] feat: bloquear facturas recibidas contabilizadas refs #7173 --- ...{invoiceIn_checkBooked.sql => invoiceIn_checkIsBooked.sql} | 2 +- db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql | 4 ++-- db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql | 1 - db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql | 1 + db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInTax_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql | 2 +- db/routines/vn/triggers/invoiceIn_afterDelete.sql | 2 +- db/routines/vn/triggers/invoiceIn_afterUpdate.sql | 1 + 10 files changed, 10 insertions(+), 9 deletions(-) rename db/routines/vn/procedures/{invoiceIn_checkBooked.sql => invoiceIn_checkIsBooked.sql} (94%) diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql similarity index 94% rename from db/routines/vn/procedures/invoiceIn_checkBooked.sql rename to db/routines/vn/procedures/invoiceIn_checkIsBooked.sql index 862870eb4..35008fcd5 100644 --- a/db/routines/vn/procedures/invoiceIn_checkBooked.sql +++ b/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkIsBooked`( vSelf INT ) BEGIN diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql index f4df48dcd..309d53af2 100644 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_b BEFORE DELETE ON `invoiceInCorrection` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.correctingFk); + CALL invoiceIn_checkIsBooked(OLD.correctingFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql index 3b0f90d0d..eed070950 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEFORE DELETE ON `invoiceInDueDay` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.id); + CALL invoiceIn_checkIsBooked(OLD.id); END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index c23ead0e4..f7e4265a7 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,7 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; - CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql index 2452ff0d1..5d58ef28b 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql index 412b091f4..e3dfc769c 100644 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_be BEFORE DELETE ON `invoiceInIntrastat` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql index a43f602b4..c48e7a227 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDe BEFORE DELETE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 3e5ecf030..99ccd2c1d 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index 90fac193d..62a01ebc2 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.id); + CALL invoiceIn_checkIsBooked(OLD.id); INSERT INTO invoiceInLog SET `action` = 'delete', diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index b1308393c..8d3df4ed5 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN + CALL invoiceIn_checkIsBooked(OLD.id); IF NEW.issued != OLD.issued OR NEW.currencyFk != OLD.currencyFk THEN From c74aea74bca2ce34b2afa723adac0e2810b5f82a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Fri, 5 Apr 2024 12:58:31 +0200 Subject: [PATCH 028/152] 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 029/152] 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 030/152] 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 031/152] 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 032/152] 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 033/152] 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 dddcacee7a417fddb9dd712d4b02e3b9424b9668 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:01:27 +0200 Subject: [PATCH 034/152] feat: refs #6500 --- db/routines/vn/procedures/riskAllClients.sql | 34 ++++---- .../vn2008/procedures/risk_vs_client_list.sql | 84 +++++++++++++++++++ 2 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 db/routines/vn2008/procedures/risk_vs_client_list.sql diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index c818c715c..f007247f3 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -2,28 +2,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + CREATE TEMPORARY TABLE tmp.client_list + (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY - SELECT id clientFk, null grade FROM client; + SELECT id Id_Cliente, null grade FROM vn.client; - CALL client_getDebt (maxRiskDate); + CALL vn2008.risk_vs_client_list(maxRiskDate); SELECT - c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais - FROM - vn2008.Clientes c - JOIN tmp.risk r ON r.clientFk = c.Id_Cliente - JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk - GROUP BY c.Id_cliente; + c.RazonSocial, + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais + FROM + vn2008.Clientes c + JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente + JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente + GROUP BY c.Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql new file mode 100644 index 000000000..92f94eb9f --- /dev/null +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -0,0 +1,84 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE) +BEGIN +/** + * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list + * + * @deprecated usar vn.client_getDebt + * @param maxRiskDate Fecha maxima de los registros + * @return table tmp.risk + */ + DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE()); + DECLARE endingDate DATETIME; + DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; + + SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE()); + SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59'); + + DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2; + CREATE TEMPORARY TABLE tmp.client_list_2 + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT * + FROM tmp.client_list; + + DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3; + CREATE TEMPORARY TABLE tmp.client_list_3 + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT * + FROM tmp.client_list; + + DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar; + 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 + 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 + WHERE Factura IS NULL + AND Fecha BETWEEN startingDate AND endingDate + GROUP BY t.Id_Cliente; + + DROP TEMPORARY TABLE IF EXISTS tmp.risk; + CREATE TEMPORARY TABLE tmp.risk + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo + FROM Clientes c + JOIN ( + SELECT clientFk, SUM(amount) amount,SUM(amount) saldo + FROM vn.clientRisk + JOIN tmp.client_list on Id_Cliente = clientFk + GROUP BY clientFk + UNION ALL + SELECT Id_Cliente, SUM(Entregado),SUM(Entregado) + FROM Recibos + JOIN tmp.client_list_2 using(Id_Cliente) + WHERE Fechacobro > endingDate + GROUP BY Id_Cliente + UNION ALL + SELECT Id_Cliente, total,0 + FROM tmp.tickets_sin_facturar + UNION ALL + SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) + FROM hedera.tpvTransaction t + JOIN tmp.client_list_3 on Id_Cliente = t.clientFk + WHERE t.receiptFk IS NULL + AND t.status = 'ok' + GROUP BY t.clientFk + ) t ON c.Id_Cliente = t.clientFk + WHERE c.activo != FALSE + GROUP BY c.Id_Cliente; + + DELETE r.* + FROM tmp.risk r + JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente + JOIN vn2008.pay_met pm on pm.id = c.pay_met_id + WHERE IFNULL(r.saldo,0) < 10 + AND r.risk <= MAX_RISK_ALLOWED + AND pm.`name` = 'TARJETA'; +END$$ +DELIMITER ; From 2d18f01a15be29e49d7382ba7f15bea77c2bd385 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:18:13 +0200 Subject: [PATCH 035/152] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index e598661af..a57e08063 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -39,7 +39,7 @@ BEGIN WHERE credit > 0; UPDATE client c - JOIN tCreditClients cc ON cc.clientFk = c.clientFk + JOIN tCreditClients cc ON cc.clientFk = c.id SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; From d595a7b2fabc01b6f0dd86df99fe908114c467e0 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:22:15 +0200 Subject: [PATCH 036/152] feat: refs #6500 --- db/versions/10984-navyDendro/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10984-navyDendro/00-firstScript.sql diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql new file mode 100644 index 000000000..136625a34 --- /dev/null +++ b/db/versions/10984-navyDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +UPDATE bs.nightTask SET `schema`='vn' WHERE id=22; + +UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE id=30; \ No newline at end of file From d3df3e3376a23db00e9d5313c93dfda33f133242 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 8 Apr 2024 12:57:01 +0200 Subject: [PATCH 037/152] 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 038/152] 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 039/152] 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 2c0c346a7bebf58566274751d5067cd5ca33c560 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Apr 2024 07:34:43 +0200 Subject: [PATCH 040/152] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 23 ++++++++++--------- .../10984-navyDendro/00-firstScript.sql | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index a57e08063..0a02f611f 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -16,31 +16,32 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tCreditClients; CREATE TEMPORARY TABLE tCreditClients - SELECT clientFk, IF (credit > recovery ,credit - recovery,0) newCredit + SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit FROM ( SELECT r.clientFk, r.amount recovery, - timestampadd(DAY, r.period, sub2.created) deadLine, + (sub2.created + INTERVAL r.period DAY) deadLine, sub2.amount credit FROM recovery r JOIN ( - SELECT clientFk, amount , created - FROM ( - SELECT * FROM clientCredit - ORDER BY created DESC - LIMIT 10000000000000000000 - ) sub + SELECT clientFk, amount, created + FROM ( + SELECT clientFk, amount, created + FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub GROUP BY clientFk ) sub2 ON sub2.clientFk = r.clientFk WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() GROUP BY r.clientFk - HAVING deadLine <= util.VN_CURDATE() + HAVING deadLine <= util.VN_CURDATE() ) sub3 WHERE credit > 0; UPDATE client c - JOIN tCreditClients cc ON cc.clientFk = c.id - SET c.credit = newCredit; + JOIN tCreditClients cc ON cc.clientFk = c.id + SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; COMMIT; diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql index 136625a34..c08462d75 100644 --- a/db/versions/10984-navyDendro/00-firstScript.sql +++ b/db/versions/10984-navyDendro/00-firstScript.sql @@ -1,4 +1,4 @@ -- Place your SQL code here -UPDATE bs.nightTask SET `schema`='vn' WHERE id=22; +UPDATE bs.nightTask SET `schema`='vn' WHERE `procedure`='raidUpdate'; -UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE id=30; \ No newline at end of file +UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE `procedure` ='recobro_credito'; \ No newline at end of file From c6ece4619fc37d0ac1270f4c225e29ad448fc324 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Apr 2024 11:40:12 +0200 Subject: [PATCH 041/152] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index 0a02f611f..f61b1499a 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -17,27 +17,27 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tCreditClients; CREATE TEMPORARY TABLE tCreditClients SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit - FROM ( - SELECT r.clientFk, - r.amount recovery, - (sub2.created + INTERVAL r.period DAY) deadLine, - sub2.amount credit - FROM recovery r - JOIN ( - SELECT clientFk, amount, created - FROM ( - SELECT clientFk, amount, created - FROM clientCredit - ORDER BY created DESC - LIMIT 10000000000000000000 - ) sub - GROUP BY clientFk - ) sub2 ON sub2.clientFk = r.clientFk - WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() - GROUP BY r.clientFk - HAVING deadLine <= util.VN_CURDATE() - ) sub3 - WHERE credit > 0; + FROM ( + SELECT r.clientFk, + r.amount recovery, + (sub2.created + INTERVAL r.period DAY) deadLine, + sub2.amount credit + FROM recovery r + JOIN ( + SELECT clientFk, amount, created + FROM ( + SELECT clientFk, amount, created + FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub + GROUP BY clientFk + ) sub2 ON sub2.clientFk = r.clientFk + WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() + GROUP BY r.clientFk + HAVING deadLine <= util.VN_CURDATE() + ) sub3 + WHERE credit > 0; UPDATE client c JOIN tCreditClients cc ON cc.clientFk = c.id From 90c26959af27b5c7abe43c20abbcd665ac50260f Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 9 Apr 2024 13:39:33 +0200 Subject: [PATCH 042/152] refs #7161 change longName to name --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 59ffa0f66..1f2dbee93 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -66,7 +66,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - longName, + name, vQuantity FROM item WHERE id = vItemFk; From 2d4524a34c2d9c2f57d177d1782110d823d4f088 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 10 Apr 2024 09:00:41 +0200 Subject: [PATCH 043/152] 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 044/152] 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 045/152] 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 046/152] 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 047/152] 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 048/152] 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 f545a57c9fe91f07d9c775a32e4d6bc9e36a3257 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 07:58:18 +0200 Subject: [PATCH 049/152] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 4 ++++ db/routines/vn/procedures/raidUpdate.sql | 5 +++-- db/routines/vn/procedures/rateView.sql | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index f61b1499a..687d652dd 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -1,6 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() BEGIN +/** + * Actualiza el crédito de los clientes + */ + DECLARE EXIT HANDLER FOR SQLSTATE '45000' BEGIN ROLLBACK; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index 214974350..abdf44ddc 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -1,7 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() BEGIN - +/** + * Actualiza el travel de las entradas de redadas + */ UPDATE entry e JOIN entryVirtual ev ON ev.entryFk = e.id JOIN travel t ON t.id = e.travelFk @@ -17,7 +19,6 @@ BEGIN JOIN travel t ON t.id = e.travelFk GROUP BY t.warehouseInFk, t.warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk - WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE ORDER BY t.landed LIMIT 10000000000000000000 diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index fb03c192a..8a6c1305d 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -1,7 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() BEGIN - +/** + * Muestra información sobre tasas de cambio de Dolares + */ SELECT t.year, t.month, From adadf70f1e18dea2961bbbb821ac6a0e8678f492 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 08:44:06 +0200 Subject: [PATCH 050/152] feat: refs #6500 --- db/routines/vn/procedures/raidUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index abdf44ddc..99a30ed04 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -22,7 +22,7 @@ BEGIN WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE ORDER BY t.landed LIMIT 10000000000000000000 - ) t + ) t GROUP BY warehouseInFk, warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk SET e.travelFk = t.id; From 622075a9aa41c22673b1b8828d4ce22747c954d7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 12 Apr 2024 09:21:34 +0200 Subject: [PATCH 051/152] fix(util): refs #7205 fix util.slowLog_prune --- db/routines/util/procedures/slowLog_prune.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql index 7294be2f6..8e8aec30f 100644 --- a/db/routines/util/procedures/slowLog_prune.sql +++ b/db/routines/util/procedures/slowLog_prune.sql @@ -6,11 +6,19 @@ BEGIN */ DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log; DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin; + DECLARE vLogExists BOOL; SET sql_log_bin = OFF; SET GLOBAL slow_query_log = OFF; - RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + SELECT COUNT(*) INTO vLogExists + FROM information_schema.TABLES + WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log'; + + IF vLogExists THEN + DROP TEMPORARY TABLE IF EXISTS `mysql`.`slow_log_temp`; + RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + END IF; DELETE FROM `mysql`.`slow_log_temp` WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); From ccf77ed356bfb24ec80d11ea6546458d59d8c81f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 12 Apr 2024 09:24:48 +0200 Subject: [PATCH 052/152] fix(util): refs #7205 util.slowLog_prune code clean --- db/routines/util/procedures/slowLog_prune.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql index 8e8aec30f..d676ae3d9 100644 --- a/db/routines/util/procedures/slowLog_prune.sql +++ b/db/routines/util/procedures/slowLog_prune.sql @@ -11,19 +11,19 @@ BEGIN SET sql_log_bin = OFF; SET GLOBAL slow_query_log = OFF; - SELECT COUNT(*) INTO vLogExists + SELECT COUNT(*) > 0 INTO vLogExists FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log'; IF vLogExists THEN - DROP TEMPORARY TABLE IF EXISTS `mysql`.`slow_log_temp`; - RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp; + RENAME TABLE mysql.slow_log TO mysql.slow_log_temp; END IF; - DELETE FROM `mysql`.`slow_log_temp` + DELETE FROM mysql.slow_log_temp WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); - RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; + RENAME TABLE mysql.slow_log_temp TO mysql.slow_log; SET GLOBAL slow_query_log = vSlowQueryLog; SET sql_log_bin = vSqlLogBin; From b4862a8ce94dc86223967b38bc20da393841eeb5 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 11:35:21 +0200 Subject: [PATCH 053/152] hotFix(claimBegginingModel): enable claimIsEditable and && --- modules/claim/back/models/claim-beginning.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index 4b870e5ea..d269b2285 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -19,7 +19,7 @@ module.exports = Self => { if (ticket.ticketFk != claim.ticketFk) throw new UserError(`Cannot create a new claimBeginning from a different ticket`); } - // await claimIsEditable(ctx); + await claimIsEditable(ctx); }); Self.observe('before delete', async ctx => { @@ -36,7 +36,7 @@ module.exports = Self => { if (ctx.options && ctx.options.transaction) myOptions.transaction = ctx.options.transaction; - const claimBeginning = await Self.findById(ctx.where.id); + const claimBeginning = ctx.instance ?? await Self.findById(ctx.where.id); const filter = { where: {id: claimBeginning.claimFk}, From f30f907d8e6fe0d0da52058f379bbc34d02fa73c Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 12:13:07 +0200 Subject: [PATCH 054/152] feat: refs #6500 cambios solicitados --- db/routines/vn/procedures/raidUpdate.sql | 6 +++--- db/routines/vn/procedures/rateView.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index 99a30ed04..703c14e5c 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -10,7 +10,7 @@ BEGIN JOIN ( SELECT * FROM ( - SELECT id, landed, tt.warehouseInFk, tt.warehouseOutFk + SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk FROM travel t JOIN ( SELECT t.warehouseInFk, t.warehouseOutFk @@ -19,11 +19,11 @@ BEGIN JOIN travel t ON t.id = e.travelFk GROUP BY t.warehouseInFk, t.warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk - WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE + WHERE shipped > util.VN_CURDATE() AND NOT isDelivered ORDER BY t.landed LIMIT 10000000000000000000 ) t - GROUP BY warehouseInFk, warehouseOutFk + GROUP BY t.warehouseInFk, t.warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk SET e.travelFk = t.id; diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 8a6c1305d..153e3584a 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -18,14 +18,14 @@ BEGIN ( SELECT t.year, t.month, - CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, - CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(SUM(p.divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(p.divisa) / SUM(p.amount) AS DECIMAL(5,4)) changePractical, CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial FROM payment p JOIN time t ON t.dated = p.received JOIN referenceRate rr ON rr.dated = p.received JOIN currency c ON c.id = rr.currencyFk - WHERE divisa + WHERE p.divisa AND c.code = 'USD' GROUP BY t.year, t.month ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH From 253465cf139491cb70836533f4f542baa8d9f8c6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:27 +0200 Subject: [PATCH 055/152] refs #7190 feat: renewToken for multimedia --- back/methods/vn-user/renew-token.js | 8 +++- .../methods/vn-user/specs/share-token.spec.js | 43 +++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index d00085d8a..bc432d7ad 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -40,9 +40,15 @@ module.exports = Self => { } }, courtesyTime * 1000); + // Get scopes + + let createTokenOptions = {}; + const {scopes} = token; + if (scopes) + createTokenOptions = {scopes: [scopes[0]]}; // Create new accessToken const user = await Self.findById(token.userId); - const accessToken = await user.createAccessToken(); + const accessToken = await user.accessTokens.create(createTokenOptions); return {id: accessToken.id, ttl: accessToken.ttl}; }; diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js index aaa83817c..e072a4fa8 100644 --- a/back/methods/vn-user/specs/share-token.spec.js +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -1,6 +1,9 @@ const {models} = require('vn-loopback/server/server'); +const TOKEN_MULTIMEDIA = 'read:multimedia'; describe('Share Token', () => { let ctx = null; + const startingTime = Date.now(); + let multimediaToken = null; beforeAll(async() => { const unAuthCtx = { req: { @@ -17,11 +20,45 @@ describe('Share Token', () => { ctx = {req: {accessToken: accessToken}}; }); - it('should renew token', async() => { - const multimediaToken = await models.VnUser.shareToken(ctx); + beforeEach(async() => { + multimediaToken = await models.VnUser.shareToken(ctx); + jasmine.clock().install(); + jasmine.clock().mockDate(new Date(startingTime)); + }); + afterEach(() => { + jasmine.clock().uninstall(); + }); + + it('should generate token', async() => { expect(Object.keys(multimediaToken).length).toEqual(1); expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId); - expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia'); + expect(multimediaToken.multimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); + }); + + it('NOT should renew', async() => { + let error; + let response; + try { + response = await models.VnUser.renewToken(ctx); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + expect(response.id).toEqual(ctx.req.accessToken.id); + }); + + it('should renew token', async() => { + const mockDate = new Date(startingTime + 26600000); + jasmine.clock().mockDate(mockDate); + + const newShareToken = await models.VnUser.renewToken({req: {accessToken: multimediaToken.multimediaToken}}); + const {id} = newShareToken; + + expect(id).not.toEqual(ctx.req.accessToken.id); + const newMultimediaToken = await models.AccessToken.findById(id); + + expect(newMultimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); }); }); From 25b5c35dc6bbe6303982b7de4dd20baddc9c8750 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:49 +0200 Subject: [PATCH 056/152] refs #6835 fix: issue --- back/methods/vn-user/renew-token.js | 3 ++- back/methods/vn-user/specs/renew-token.spec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index bc432d7ad..2fd1f43c0 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -33,7 +33,8 @@ module.exports = Self => { // Schedule to remove current token setTimeout(async() => { try { - await Self.logout(token.id); + const exists = await models.AccessToken.findById(token.id); + exists && await Self.logout(token.id); } catch (err) { // eslint-disable-next-line no-console console.error(err); diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8d9bbf11c..741388bf9 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -33,6 +33,17 @@ describe('Renew Token', () => { const {id} = await models.VnUser.renewToken(ctx); expect(id).not.toEqual(ctx.req.accessToken.id); + + await models.VnUser.logout(ctx.req.accessToken.id); + jasmine.clock().tick(70 * 1000); + let tokenNotExists; + try { + tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id); + } catch (e) { + error = e; + } + + expect(tokenNotExists).toBeNull(); }); it('NOT should renew', async() => { From a68b8431c5915ec958478f3d5112c6d4c504080d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 10:21:59 +0200 Subject: [PATCH 057/152] feat: refs #6938 add scope & acls --- .../10994-wheatLaurel/00-modifyAcls.sql | 4 ++ modules/worker/back/models/worker.json | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 db/versions/10994-wheatLaurel/00-modifyAcls.sql diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql new file mode 100644 index 000000000..5b264482a --- /dev/null +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index ed430f133..4b7e4a512 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -92,5 +92,58 @@ "model": "WorkerTeamCollegues", "foreignKey": "workerFk" } + }, + "scopes":{ + "summary": { + "fields": [ + [ + "id", + "firstName", + "lastName", + "bossFk", + "maritalStatus", + "originCountryFk", + "educationLevelFk", + "SSN", + "mobileExtension", + "code", + "locker", + "fi", + "birth", + "isF11Allowed" + ] + + ], + "include": [ + { + "relation": "user", + "scope": { + "fields": ["email", "name", "nickname", "roleFk"], + "include": { + "relation": "role", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "department", + "scope": { + "include": { + "relation": "department", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "boss" + }, { + "relation": "client" + }, { + "relation": "sip" + } + ] + } } } From 200cbd8d74bedf95605c3b8ab260fb2155100494 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 11:03:57 +0200 Subject: [PATCH 058/152] fix: refs #6938 acls & scope --- db/versions/10994-wheatLaurel/00-modifyAcls.sql | 2 +- modules/worker/back/models/worker.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql index 5b264482a..905f67aba 100644 --- a/db/versions/10994-wheatLaurel/00-modifyAcls.sql +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -1,4 +1,4 @@ UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) - VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + VALUES ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4b7e4a512..0c4f91118 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -96,7 +96,6 @@ "scopes":{ "summary": { "fields": [ - [ "id", "firstName", "lastName", @@ -112,8 +111,7 @@ "birth", "isF11Allowed" ] - - ], + , "include": [ { "relation": "user", From 42fe7fb1e23e47cf6b07d846dd0ea57a3f1e9481 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 15 Apr 2024 11:32:44 +0200 Subject: [PATCH 059/152] feat(binlog): refs #4409 Disable order recalc from triggers --- db/routines/hedera/events/order_doRecalc.sql | 2 +- db/routines/hedera/procedures/order_requestRecalc.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql index d355e1a55..bbc61924f 100644 --- a/db/routines/hedera/events/order_doRecalc.sql +++ b/db/routines/hedera/events/order_doRecalc.sql @@ -3,6 +3,6 @@ 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 + DISABLE DO CALL order_doRecalc$$ DELIMITER ; diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql index 4bcb1010e..990894bb6 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 Disable order recalc + -- INSERT INTO orderRecalc SET orderFk = vSelf; END$$ DELIMITER ; From d7b06fe637ca4662cdd8672ba287ca03a2f07c76 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 12:47:27 +0200 Subject: [PATCH 060/152] fix: refs #6938 scope --- modules/worker/back/models/worker.json | 67 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 0c4f91118..10776af90 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -95,23 +95,6 @@ }, "scopes":{ "summary": { - "fields": [ - "id", - "firstName", - "lastName", - "bossFk", - "maritalStatus", - "originCountryFk", - "educationLevelFk", - "SSN", - "mobileExtension", - "code", - "locker", - "fi", - "birth", - "isF11Allowed" - ] - , "include": [ { "relation": "user", @@ -128,16 +111,56 @@ "relation": "department", "scope": { "include": { - "relation": "department", - "scope": { - "fields": ["name"] - } + "relation": "department" } } }, { "relation": "boss" }, { - "relation": "client" + "relation": "client", + "scope": { + "fields": [ + "id", + "name", + "fi", + "socialName", + "contact", + "street", + "city", + "postcode", + "email", + "mobile", + "isActive", + "credit", + "creditInsurance", + "iban", + "dueDay", + "isEqualizated", + "isFreezed", + "hasToInvoiceByAddress", + "hasToInvoice", + "isToBeMailed", + "hasSepaVnl", + "hasLcr", + "hasCoreVnl", + "hasCoreVnh", + "hasIncoterms", + "isTaxDataChecked", + "eypbc", + "quality", + "isVies", + "isRelevant", + "accountingAccount", + "created", + "sageTaxTypeFk", + "sageTransactionTypeFk", + "businessTypeFk", + "salesPersonFk", + "hasElectronicInvoice", + "rating", + "recommendedCredit" + ] + } }, { "relation": "sip" } From 5c524ecc7db005c933f0d6657ed86ad8daca9c01 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 13:13:40 +0200 Subject: [PATCH 061/152] rollback: refs #6724 entry.js --- modules/entry/back/models/entry.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 9d5cd4e1f..6148ae559 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -46,15 +46,4 @@ module.exports = Self => { } } }); - - Self.observe('before delete', async function(ctx) { - let isBooked = ctx.instance && ctx.instance.isBooked; - - if (isBooked === undefined) { - const entryInstance = await Self.findById(ctx.where.id); - isBooked = entryInstance.isBooked; - } - - if (isBooked) throw new Error('Booked entry cannot be deleted'); - }); }; From 0f26fb46b6f0127b1bcf4b54b1656749fb5dd8f7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 13:16:36 +0200 Subject: [PATCH 062/152] feat: refs #6724 Grant changes --- .../10944-tealLaurel/00-firstScript.sql | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql index d11bcb333..2d61cde90 100644 --- a/db/versions/10944-tealLaurel/00-firstScript.sql +++ b/db/versions/10944-tealLaurel/00-firstScript.sql @@ -1,10 +1,8 @@ - - REVOKE UPDATE ON vn.entry FROM entryEditor; - GRANT UPDATE ON vn.entry TO administrative; - - GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable, - isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk, - currencyFk,companyFk, gestDocFk, invoiceInFk, isBlocked, loadPriority, - kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, - observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked - ) ON vn.entry TO entryEditor; +REVOKE UPDATE ON vn.entry FROM entryEditor; +GRANT UPDATE ON vn.entry TO administrative; +GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable, + isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk, + currencyFk,companyFk, gestDocFk, invoiceInFk, loadPriority, + kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, + observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked +) ON vn.entry TO entryEditor; From 339c349ed037c6454e585c7e5b6a876465ec5365 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 14:00:54 +0200 Subject: [PATCH 063/152] feat: refs #6724 Added admon acl to vn-check --- modules/entry/front/basic-data/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 6bccb0b5f..57de1c5f7 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -123,7 +123,9 @@ + ng-model="$ctrl.entry.isBooked" + vn-acl="administrative" + > From 3e1218463c03b2cda4ea390a262299b49d661fac Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 14:44:18 +0200 Subject: [PATCH 064/152] fix: refs #6938 filters & scope --- modules/worker/back/models/worker.json | 18 ++++++--- modules/worker/front/card/index.js | 32 ++-------------- modules/worker/front/descriptor/index.js | 36 ++--------------- modules/worker/front/summary/index.js | 49 +++--------------------- 4 files changed, 25 insertions(+), 110 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 10776af90..57dc80ec9 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -100,12 +100,20 @@ "relation": "user", "scope": { "fields": ["email", "name", "nickname", "roleFk"], - "include": { - "relation": "role", - "scope": { - "fields": ["name"] + "include": [ + { + "relation": "role", + "scope": { + "fields": ["name"] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": ["email"] + } } - } + ] } }, { "relation": "department", diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..1aa548db9 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'sip', - scope: { - fields: ['extension', 'secret'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: { + id: this.$params.id} }; return Promise.all([ - this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data), + this.$http.get(`Workers/summary`, {filter}) + .then(res => this.worker = res.data[0]), this.$http.get(`Workers/${this.$params.id}/activeContract`) .then(res => this.hasWorkCenter = res.data?.workCenterFk) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index d7962369c..ebf3d65ed 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -37,41 +37,11 @@ class Controller extends Descriptor { loadData() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'client', - scope: { - fields: ['fi'] - } - }, { - relation: 'sip', - scope: { - fields: ['extension'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: {id: this.id}, }; - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData(`Workers/summary`, {filter}) + .then(res => this.entity = res.data[0]); } getPassRequirements() { diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 212609f58..d1a27a6d4 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -10,53 +10,14 @@ class Controller extends Summary { this.$.worker = null; if (!value) return; - const query = `Workers/${value.id}`; const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'roleFk'], - include: [{ - relation: 'role', - scope: { - fields: ['name'] - } - }, - { - relation: 'emailUser', - scope: { - fields: ['email'] - } - }] - } - }, - { - relation: 'client', - scope: {fields: ['fi', 'phone']} - }, - { - relation: 'boss', - scope: {fields: ['id', 'name']} - }, - { - relation: 'sip', - scope: {fields: ['extension']} - }, - { - relation: 'department', - scope: { - include: { - relation: 'department', - scope: {fields: ['id', 'code', 'name']} - } - } - } - ] + where: { + id: value.id + } }; - this.$http.get(query, {params: {filter}}).then(res => { - this.$.worker = res.data; + this.$http.get(`Workers/summary`, {filter}).then(res => { + this.$.worker = res.data[0]; }); } From 3c9ac9634b6c4ab5890bb232d2d68b9d12eb9a63 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:02:45 +0200 Subject: [PATCH 065/152] fix: refs #6938 front tests --- modules/worker/front/descriptor/index.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index 4f7fa6a05..cee8b0def 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = 'foo'; + const response = ['foo']; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + $httpBackend.expectRoute('GET', `Workers/summary`).respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect([controller.worker]).toEqual(response); }); }); From adb2249d2f8b4a74149e195b471963b2e317aade Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:09:41 +0200 Subject: [PATCH 066/152] fix: refs #6938 e2e tests --- e2e/paths/03-worker/01_summary.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js index 51992b41d..3c6149726 100644 --- a/e2e/paths/03-worker/01_summary.spec.js +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Worker summary path', () => { - const workerId = 3; let browser; let page; beforeAll(async() => { @@ -10,7 +9,7 @@ describe('Worker summary path', () => { page = browser.page; await page.loginAndModule('employee', 'worker'); const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); + return response.status() === 200 && response.url().includes(`Workers/summary`); }); await page.accessToSearchResult('agencyNick'); await httpDataResponse; From 6e183b74264099ed0cb928d5f6d6ad3698f6e848 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 15 Apr 2024 15:59:05 +0200 Subject: [PATCH 067/152] refs #7161 change vAddress to vAddressShortage --- db/routines/vn/procedures/itemTrash.sql | 56 +++++++++++++++++++ .../vn/procedures/item_setVisibleDiscard.sql | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql new file mode 100644 index 000000000..bbb30b78a --- /dev/null +++ b/db/routines/vn/procedures/itemTrash.sql @@ -0,0 +1,56 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`( + vItemFk INT, + vWarehouseFk INT, + vQuantity INT, + vIsTrash BOOLEAN) +BEGIN + DECLARE vTicketFk INT; + DECLARE vClientFk INT; + DECLARE vCompanyVnlFk INT DEFAULT 442; + DECLARE vCalc INT; + + SELECT barcodeToItem(vItemFk) INTO vItemFk; + + SELECT IF(vIsTrash, 200, 400) INTO vClientFk; + + SELECT t.id INTO vTicketFk + FROM ticket t + JOIN address a ON a.id=t.addressFk + WHERE t.warehouseFk = vWarehouseFk + AND t.clientFk = vClientFk + AND DATE(t.shipped) = util.VN_CURDATE() + AND a.isDefaultAddress + LIMIT 1; + + CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); + + IF vTicketFk IS NULL THEN + CALL ticket_add( + vClientFk, + util.VN_CURDATE(), + vWarehouseFk, + vCompanyVnlFk, + NULL, + NULL, + NULL, + util.VN_CURDATE(), + account.myUser_getId(), + FALSE, + vTicketFk); + END IF; + + INSERT INTO sale(ticketFk, itemFk, concept, quantity) + SELECT vTicketFk, + vItemFk, + CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + vQuantity + FROM item + WHERE id = vItemFk; + + UPDATE cache.visible + SET visible = visible - vQuantity + WHERE calc_id = vCalc + AND item_id = vItemFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1f2dbee93..0a6c54971 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -34,7 +34,7 @@ BEGIN SELECT a.clientFk INTO vClientFk FROM address a - WHERE a.id = vAddressFk; + WHERE a.id = vAddressShortage; SELECT t.id INTO vTicketFk FROM ticket t From d24de61213e68fea6df21da0d8e7ae7c970a62c3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Apr 2024 08:29:39 +0200 Subject: [PATCH 068/152] 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 93abfdd8a1e8d2bd2508300918518d38e4b1d984 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 08:44:50 +0200 Subject: [PATCH 069/152] feat: refs #7173 Added restrictions in invoiceIn structure --- db/dump/fixtures.before.sql | 16 ++++++++++------ .../vn/procedures/invoiceInTax_afterUpsert.sql | 2 ++ ...eckIsBooked.sql => invoiceIn_checkBooked.sql} | 2 +- .../invoiceInCorrection_beforeDelete.sql | 2 +- .../vn/triggers/invoiceInDueDay_beforeDelete.sql | 4 ++-- .../vn/triggers/invoiceInDueDay_beforeInsert.sql | 2 ++ .../triggers/invoiceInIntrastat_beforeDelete.sql | 2 +- .../triggers/invoiceInIntrastat_beforeInsert.sql | 8 ++++++++ ...tesql => invoiceInIntrastat_beforeUpdate.sql} | 0 .../vn/triggers/invoiceInTax_beforeDelete.sql | 2 +- .../vn/triggers/invoiceInTax_beforeUpdate.sql | 2 +- .../vn/triggers/invoiceIn_afterDelete.sql | 2 -- .../vn/triggers/invoiceIn_afterUpdate.sql | 2 -- .../vn/triggers/invoiceIn_beforeDelete.sql | 8 ++++++++ .../vn/triggers/invoiceIn_beforeUpdate.sql | 4 +++- .../methods/invoice-in-due-day/specs/new.spec.js | 3 +-- .../back/methods/invoice-in/specs/filter.spec.js | 2 +- 17 files changed, 42 insertions(+), 21 deletions(-) rename db/routines/vn/procedures/{invoiceIn_checkIsBooked.sql => invoiceIn_checkBooked.sql} (94%) create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql rename db/routines/vn/triggers/{invoiceInIntrastat_beforeUpdatesql => invoiceInIntrastat_beforeUpdate.sql} (100%) create mode 100644 db/routines/vn/triggers/invoiceIn_beforeDelete.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1dad68b2c..cca080e45 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2542,15 +2542,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) VALUES (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), - (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1), (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), - (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1), (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), - (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1), - (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1), - (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), - (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`) VALUES @@ -2605,6 +2605,10 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); +UPDATE `vn`.`invoiceIn` + SET isBooked = TRUE + WHERE id IN (2, 5, 7, 8, 9, 10); + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT t.id FROM vn.ticket t diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 60ec34696..43d54c28c 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -10,6 +10,8 @@ BEGIN DECLARE vLines INT; DECLARE vHasDistinctTransactions INT; + CALL invoiceIn_checkBooked(vInvoiceInFk); + SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; SELECT COUNT(*) INTO vLines diff --git a/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql similarity index 94% rename from db/routines/vn/procedures/invoiceIn_checkIsBooked.sql rename to db/routines/vn/procedures/invoiceIn_checkBooked.sql index 35008fcd5..862870eb4 100644 --- a/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkIsBooked`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( vSelf INT ) BEGIN diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql index 309d53af2..f4df48dcd 100644 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_b BEFORE DELETE ON `invoiceInCorrection` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.correctingFk); + CALL invoiceIn_checkBooked(OLD.correctingFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql index eed070950..10c9d0b52 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEFORE DELETE ON `invoiceInDueDay` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.id); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..95b227616 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(NEW.invoiceInFk); + SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql index e3dfc769c..412b091f4 100644 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_be BEFORE DELETE ON `invoiceInIntrastat` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql new file mode 100644 index 000000000..d6c25c505 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert` + BEFORE INSERT ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(NEW.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql similarity index 100% rename from db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql rename to db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql index c48e7a227..a43f602b4 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDe BEFORE DELETE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 99ccd2c1d..3e5ecf030 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index 62a01ebc2..c088f6492 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.id); - INSERT INTO invoiceInLog SET `action` = 'delete', `changedModel` = 'InvoiceIn', diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 8d3df4ed5..1a9105c9e 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.id); - IF NEW.issued != OLD.issued OR NEW.currencyFk != OLD.currencyFk THEN diff --git a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql new file mode 100644 index 000000000..2ffff923a --- /dev/null +++ b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete` + BEFORE DELETE ON `invoiceIn` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.id); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 688a3af92..d0762de96 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN DECLARE vWithholdingSageFk INT; - CALL invoiceIn_checkBooked(OLD.id); + IF NEW.isBooked = OLD.isBooked THEN + CALL invoiceIn_checkBooked(OLD.id); + END IF; IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN CALL util.throw('The invoiceIn reference contains invalid characters'); diff --git a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js index c188a511d..f21dad9f2 100644 --- a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js @@ -13,11 +13,10 @@ describe('invoiceInDueDay new()', () => { it('should correctly create a new due day', async() => { const userId = 9; - const invoiceInFk = 6; + const invoiceInFk = 3; const ctx = { req: { - accessToken: {userId: userId}, } }; 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 9834989fc..3ff5a92f3 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(6); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { From 45fac06c6b6bf82d38cc105f45055cb1044d4693 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 08:58:26 +0200 Subject: [PATCH 070/152] feat: refs #7173 Added restrictions in invoiceIn structure --- .../vn/triggers/invoiceInCorrection_beforeInsert.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql new file mode 100644 index 000000000..aec58a265 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeInsert` + BEFORE INSERT ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(NEW.correctingFk); +END$$ +DELIMITER ; From 7a557be09a0256d95636dbfc34d9c80daecb4e6b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 11:07:57 +0200 Subject: [PATCH 071/152] feat: refs #6968 Changed groupingMode to enum --- db/dump/fixtures.before.sql | 52 +++++++++---------- db/routines/edi/procedures/ekt_load.sql | 3 +- .../procedures/floramondo_offerRefresh.sql | 10 ++-- .../procedures/catalog_componentCalculate.sql | 7 +-- .../vn/procedures/collectionPlacement_get.sql | 4 +- db/routines/vn/procedures/inventoryMake.sql | 2 +- db/routines/vn/procedures/item_getSimilar.sql | 4 +- .../vn/procedures/sale_replaceItem.sql | 8 ++- db/routines/vn/triggers/buy_beforeInsert.sql | 2 +- db/versions/10997-crimsonCyca/00-part1.sql | 2 + db/versions/10997-crimsonCyca/01-part2.sql | 7 +++ db/versions/10997-crimsonCyca/02-part3.sql | 2 + modules/entry/back/models/buy.json | 2 +- modules/entry/front/buy/index/index.html | 8 +-- modules/entry/front/buy/index/index.js | 8 +-- modules/entry/front/buy/index/index.spec.js | 27 +++------- modules/entry/front/latest-buys/index.html | 4 +- modules/entry/front/summary/index.html | 4 +- modules/item/front/last-entries/index.html | 4 +- 19 files changed, 77 insertions(+), 83 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-part1.sql create mode 100644 db/versions/10997-crimsonCyca/01-part2.sql create mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c9832545f..277734eb7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1492,21 +1492,21 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), - (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), - (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), - (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), - (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), - (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), - (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), - (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES @@ -3235,7 +3235,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3273,7 +3273,7 @@ INSERT INTO vn.buy stickers = 1, packing = 40, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3311,7 +3311,7 @@ INSERT INTO vn.buy stickers = 2, packing = 10, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3357,7 +3357,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 4, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3395,7 +3395,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3434,7 +3434,7 @@ INSERT INTO vn.buy stickers = 1, packing = 200, `grouping` = 30, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3473,7 +3473,7 @@ INSERT INTO vn.buy stickers = 1, packing = 500, `grouping` = 10, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3512,7 +3512,7 @@ INSERT INTO vn.buy stickers = 2, packing = 300, `grouping` = 50, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3551,7 +3551,7 @@ INSERT INTO vn.buy stickers = 2, packing = 50, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3591,7 +3591,7 @@ INSERT vn.buy stickers = 1, packing = 5, `grouping` = 2, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, @@ -3630,7 +3630,7 @@ INSERT vn.buy stickers = 1, packing = 100, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index ccdcd1999..a72f48674 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -14,7 +14,6 @@ proc:BEGIN DECLARE vPackage INT; DECLARE vPutOrderFk INT; DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vEntryFk INT; DECLARE vHasToChangePackagingFk BOOLEAN; DECLARE vIsFloramondoDirect BOOLEAN; @@ -150,7 +149,7 @@ proc:BEGIN @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, - vForceToPacking, + 'packing', IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk), (IFNULL(i.weightByPiece, 0) * @pac) / 1000 FROM ekt e diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 26e09ebaf..18d3f8b7e 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; DECLARE vDone INT DEFAULT FALSE; @@ -417,7 +417,7 @@ proc: BEGIN o.NumberOfUnits etiquetas, o.NumberOfItemsPerCask packing, GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 2, -- Obliga al Packing + 'packing', o.embalageCode, o.diId FROM edi.offer o @@ -518,5 +518,5 @@ proc: BEGIN fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 1af0ff9eb..4b860103d 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -48,7 +48,7 @@ BEGIN IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3, IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + b.groupingMode groupingMode, tl.buyFk, i.typeFk, IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping @@ -252,14 +252,15 @@ BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + IF(tcc.groupingMode = 'grouping', tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) + AND NOT tcc.groupingMode = 'packing' + AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL) GROUP BY tcs.warehouseFk, tcs.itemFk; INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 3641ba705..3fb3339e7 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -40,8 +40,8 @@ BEGIN ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing + WHEN NULL THEN 1 + WHEN 'packing' THEN b.packing ELSE b.`grouping` END `grouping` FROM buy b diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index c50d75b05..b7ea377d2 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -116,7 +116,7 @@ BEGIN freightValue decimal(10,3) DEFAULT '0.000', packing int(11) DEFAULT '1', `grouping` smallint(5) unsigned NOT NULL DEFAULT '1', - groupingMode tinyint(4) NOT NULL DEFAULT 0 , + groupingMode enum('grouping', 'packing') DEFAULT NULL, comissionValue decimal(10,3) DEFAULT '0.000', packageValue decimal(10,3) DEFAULT '0.000', packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index f79bed375..1da60cf70 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -61,8 +61,8 @@ BEGIN a.available, IFNULL(ip.counter, 0) `counter`, CASE - WHEN b.groupingMode = 1 THEN b.grouping - WHEN b.groupingMode = 2 THEN b.packing + WHEN b.groupingMode = 'grouping' THEN b.grouping + WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END AS minQuantity, iss.visible located diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 82c5d1ec2..2514c14c7 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk INT; + DECLARE vGroupingModeFk VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -23,8 +23,6 @@ BEGIN DECLARE vOldPrice DECIMAL(10,2); DECLARE vOption VARCHAR(255); DECLARE vNewSaleFk INT; - DECLARE vForceToGrouping INT DEFAULT 1; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vFinalPrice DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION @@ -63,10 +61,10 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN + IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN + IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index bc51ac852..6ad72916b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -6,7 +6,7 @@ trig: BEGIN DECLARE vWarehouse INT; DECLARE vLanding DATE; DECLARE vGrouping INT; - DECLARE vGroupingMode TINYINT; + DECLARE vGroupingMode VARCHAR(255); DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; DECLARE vBuyerFk INT; diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql new file mode 100644 index 000000000..8811b81a7 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-part1.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql new file mode 100644 index 000000000..1f7a3c9f6 --- /dev/null +++ b/db/versions/10997-crimsonCyca/01-part2.sql @@ -0,0 +1,7 @@ +UPDATE vn.buy + SET groupingMode2 = 'packing' + WHERE groupingMode = 2; + +UPDATE vn.buy + SET groupingMode2 = 'grouping' + WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql new file mode 100644 index 000000000..c63560957 --- /dev/null +++ b/db/versions/10997-crimsonCyca/02-part3.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index fa804f4d8..35861fd81 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -34,7 +34,7 @@ "type": "number" }, "groupingMode": { - "type": "number" + "type": "string" }, "comissionValue": { "type": "number" diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index 203d6c522..0e0c69788 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -119,13 +119,13 @@ @@ -140,13 +140,13 @@ diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index c991b745b..9131c31f6 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -53,12 +53,8 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const grouping = 1; - const packing = 2; - const groupingMode = mode === 'grouping' ? grouping : packing; - - const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; - + const groupingMode = mode === 'grouping' ? mode : 'packing'; + const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; const params = { groupingMode: newGroupingMode }; diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9d5fab51..f5c6d1bdb 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -57,45 +57,34 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: grouping}; + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was packing to packing`, () => { - const noGrouping = 0; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const noGrouping = 0; - const grouping = 1; - const buy = {id: 999, groupingMode: grouping}; - + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 16e039cf0..2e6de83b9 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -143,12 +143,12 @@ - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 655dcd66f..baa310bb6 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -121,12 +121,12 @@ {{::line.packagingFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}} diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 429955ef5..e3b84655c 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -71,12 +71,12 @@ {{entry.stickers | dashIfEmpty}} - + {{::entry.packing | dashIfEmpty}} - + {{::entry.grouping | dashIfEmpty}} From 7fda58d4a4fef14dcd557c90fa7be07caadcf122 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 12:29:44 +0200 Subject: [PATCH 072/152] hotfix: ticket#174308 Ekt load packing --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index ccdcd1999..adbaf4628 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, + @pac := GREATEST(1, i.stemMultiplier * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, From 01d959f6f4ca1efec573298222f8f1380cb85161 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 16 Apr 2024 12:46:50 +0200 Subject: [PATCH 073/152] feat: refs #7219 --- db/routines/vn/procedures/sale_replaceItem.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 82c5d1ec2..1d9f6ff71 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -81,10 +81,6 @@ BEGIN ORDER BY (vQuantity % `grouping`) ASC LIMIT 1; - IF vNewPrice IS NULL THEN - CALL util.throw('price retrieval failed'); - END IF; - IF vNewPrice > vOldPrice THEN SET vFinalPrice = vOldPrice; SET vOption = 'substitution'; From f5fd70889124a7d27a1eb81fdd5c7b659c0d1ef8 Mon Sep 17 00:00:00 2001 From: pako Date: Tue, 16 Apr 2024 17:08:45 +0200 Subject: [PATCH 074/152] item_get --- db/routines/floranet/procedures/item_get.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/routines/floranet/procedures/item_get.sql diff --git a/db/routines/floranet/procedures/item_get.sql b/db/routines/floranet/procedures/item_get.sql new file mode 100644 index 000000000..44f01f2a1 --- /dev/null +++ b/db/routines/floranet/procedures/item_get.sql @@ -0,0 +1,15 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.item_get(vCatalogueFk INT) +READS SQL DATA +BEGIN +/** + * Returns one recordset from catalogue + * + * @param vCatalogueFk Identifier de vn.catalogue + */ + SELECT * + FROM catalogue + WHERE id = vCatalogueFk; +END$$ +DELIMITER ; From db5b0d79676d2b3f9f75e5c44e3135dac3a08770 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 17:19:25 +0200 Subject: [PATCH 075/152] hotfix: ticket#174761 Greatest fix null possibility --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index adbaf4628..34814453b 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := GREATEST(1, i.stemMultiplier * e.pac / @t) packing, + @pac := GREATEST(1, IFNULL(i.stemMultiplier * e.pac / @t, 0)) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, From f05b33787f32d3645159b79bac3a3402071a9792 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:42:36 +0200 Subject: [PATCH 076/152] feat: refs #6021 order_put refactor --- db/routines/floranet/procedures/order_put.sql | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index 564587268..979588f8f 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -1,41 +1,21 @@ -DROP PROCEDURE IF EXISTS floranet.order_put; - DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON) READS SQL DATA BEGIN /** * Get and process an order. * - * @param vOrder Data of the order - * - * Customer data: , , - * - * Item data: , - * - * Delivery data: ,
, - * + * @param vJsonData The order data in json format */ - INSERT IGNORE INTO `order`( - catalogueFk, - customerName, - email, - customerPhone, - message, - deliveryName, - address, - deliveryPhone - ) - VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone')) - ); + INSERT INTO `order` + SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), + customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), + email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), + customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')), + message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), + deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), + address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); SELECT LAST_INSERT_ID() orderFk; END$$ From 70836b93b6186413f132a814290a14a58f7d5906 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:51:34 +0200 Subject: [PATCH 077/152] fix: refs #6021 catalogue_findById --- .../procedures/{item_get.sql => catalogue_findById.sql} | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename db/routines/floranet/procedures/{item_get.sql => catalogue_findById.sql} (71%) diff --git a/db/routines/floranet/procedures/item_get.sql b/db/routines/floranet/procedures/catalogue_findById.sql similarity index 71% rename from db/routines/floranet/procedures/item_get.sql rename to db/routines/floranet/procedures/catalogue_findById.sql index 44f01f2a1..7058ae03c 100644 --- a/db/routines/floranet/procedures/item_get.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -1,6 +1,6 @@ DELIMITER $$ $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.item_get(vCatalogueFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT) READS SQL DATA BEGIN /** @@ -8,8 +8,6 @@ BEGIN * * @param vCatalogueFk Identifier de vn.catalogue */ - SELECT * - FROM catalogue - WHERE id = vCatalogueFk; + SELECT * FROM catalogue WHERE id = vCatalogueFk; END$$ DELIMITER ; From 1d29c77aa7148a74b8697e7d707b7dd1c2cf1d74 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:53:21 +0200 Subject: [PATCH 078/152] feat: refs #6021 fix proc --- db/routines/floranet/procedures/catalogue_findById.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql index 7058ae03c..728eb8519 100644 --- a/db/routines/floranet/procedures/catalogue_findById.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -6,7 +6,7 @@ BEGIN /** * Returns one recordset from catalogue * - * @param vCatalogueFk Identifier de vn.catalogue + * @param vCatalogueFk Identifier de floranet.catalogue */ SELECT * FROM catalogue WHERE id = vCatalogueFk; END$$ From e15fb8dec69a17e0d3535b6bff21899d5dbad30d Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 18:00:15 +0200 Subject: [PATCH 079/152] fix: refs #6021 proc --- db/routines/floranet/procedures/catalogue_findById.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql index 728eb8519..aca6ca4d6 100644 --- a/db/routines/floranet/procedures/catalogue_findById.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -8,6 +8,6 @@ BEGIN * * @param vCatalogueFk Identifier de floranet.catalogue */ - SELECT * FROM catalogue WHERE id = vCatalogueFk; + SELECT * FROM catalogue WHERE id = vSelf; END$$ DELIMITER ; From c8e7706652702ff5106359c2d1e1f17c7de9e6fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 07:15:24 +0200 Subject: [PATCH 080/152] feat: refs #6968 Requested changes --- db/routines/vn/procedures/sale_replaceItem.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 2514c14c7..9fece1ebd 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk VARCHAR(255); + DECLARE vGroupingMode VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -56,15 +56,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing - INTO vGrouping,vGroupingModeFk,vPacking + INTO vGrouping,vGroupingMode,vPacking FROM buy b JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN + IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; From bc2b6ff97ea63912bc790d6278357d46b0f50a64 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 07:25:46 +0200 Subject: [PATCH 081/152] feat: refs #7173 Added traduction --- loopback/locale/es.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8b02f3048..d7f9564fe 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -352,5 +352,6 @@ "The line could not be marked": "La linea no puede ser marcada", "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario", "They're not your subordinate": "No es tu subordinado/a.", - "No results found": "No se han encontrado resultados" + "No results found": "No se han encontrado resultados", + "InvoiceIn is already booked": "La factura recibida está contabilizada" } \ No newline at end of file From 187c918a21e0c7c2add31df5aa52195ea94788b6 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 17 Apr 2024 07:33:08 +0200 Subject: [PATCH 082/152] 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 083/152] 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 786a5a68b91632f922bb7be8753bf52f76fa885a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 08:40:25 +0200 Subject: [PATCH 084/152] hotfix: EKT --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index 34814453b..08ecddf1d 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := GREATEST(1, IFNULL(i.stemMultiplier * e.pac / @t, 0)) packing, + @pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, From 6214da2c42eec2b1604bed71c76747e2418e4add Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 09:52:53 +0200 Subject: [PATCH 085/152] feat(salix): refs #6930 Undo rollback salix-back --- 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 | 3 ++- 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, 23 insertions(+), 22 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index 6f2451505..d64b15b70 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: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index 4aa40197f..a1776cde5 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: ['read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 9ac06f30b..201e16164 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: ['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 390be33b9..4b66bd418 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: ['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 7e49708f5..61784f39e 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: ['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 14ae8646d..20c35494e 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: ['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 2f6489d3f..93c1b6bd9 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: ['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 24fb9fde3..cb71121d5 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: ['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 13305f6ed..4f2a8aab3 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: ['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 a2d877189..0b08aec6d 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: ['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 6208d0625..6822e5a23 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: ['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 6970bf368..6ac56b68c 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: ['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 354771071..e1bc248ae 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: ['read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index cd7ef57ce..08a8182e0 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/:id/cmr', verb: 'GET' - } + }, + accessScopes: ['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 1ef25d175..43f6e9648 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: ['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 b226cf7f8..d7fc30aa3 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: ['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 9469356bb..e7b4dee17 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: ['read:multimedia'] }); diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 55767e9c6..51c626e69 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: ['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 29a859842..9fa3c183e 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: ['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 6155ff81e..adc9e4435 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: ['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 0c7f0a682..73748ac50 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: ['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 871bbffde..08fbcf924 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: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From 0a4cd4d4d02f74271ffebf3e7c71bf5f00e7ca4a Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 09:58:27 +0200 Subject: [PATCH 086/152] feat: company_getSuppliersDebtHotFix --- .../procedures/company_getSuppliersDebt.sql | 360 +++++++++--------- 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql index f4814abcc..50c64669c 100644 --- a/db/routines/vn/procedures/company_getSuppliersDebt.sql +++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql @@ -7,195 +7,195 @@ BEGIN * @param vSelf company id * @param vMonthAgo time interval to be consulted */ - DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); - DECLARE vCurrencyEuroFk INT; - DECLARE vStartDate DATE; - DECLARE vInvalidBalances DOUBLE; + DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); + DECLARE vCurrencyEuroFk INT; + DECLARE vStartDate DATE; + DECLARE vInvalidBalances DOUBLE; - SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; - SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; + SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; + SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; - DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; - CREATE TEMPORARY TABLE tOpeningBalances ( - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - openingBalances DOUBLE NOT NULL, - closingBalances DOUBLE NOT NULL, - currencyFk INT NOT NULL, - PRIMARY KEY (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; + CREATE TEMPORARY TABLE tOpeningBalances ( + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + openingBalances DOUBLE NOT NULL, + closingBalances DOUBLE NOT NULL, + currencyFk INT NOT NULL, + PRIMARY KEY (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - -- Calculates the opening and closing balance for each supplier - INSERT INTO tOpeningBalances - SELECT supplierFk, - companyFk, - SUM(amount * isBeforeStarting) AS openingBalances, - SUM(amount) closingBalances, - currencyFk - FROM ( - SELECT p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, - p.dueDated < vStartingDate isBeforeStarting, - p.currencyFk - FROM payment p - WHERE p.received > vStartDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.supplierFk, - r.companyFk, - - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, - rv.dueDated < vStartingDate isBeforeStarting, - r.currencyFk - FROM invoiceIn r - INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE r.issued > vStartDate - AND r.isBooked - AND r.companyFk = vSelf - ) sub GROUP BY companyFk, supplierFk, currencyFk; + -- Calculates the opening and closing balance for each supplier + INSERT INTO tOpeningBalances + SELECT supplierFk, + companyFk, + SUM(amount * isBeforeStarting) AS openingBalances, + SUM(amount) closingBalances, + currencyFk + FROM ( + SELECT p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, + p.dueDated < vStartingDate isBeforeStarting, + p.currencyFk + FROM payment p + WHERE p.received > vStartDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.supplierFk, + r.companyFk, + - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, + rv.dueDated < vStartingDate isBeforeStarting, + r.currencyFk + FROM invoiceIn r + INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE r.issued > vStartDate + AND r.isBooked + AND r.companyFk = vSelf + ) sub GROUP BY companyFk, supplierFk, currencyFk; - DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; - CREATE TEMPORARY TABLE tPendingDuedates ( - id INT auto_increment, - expirationId INT, - dated DATE, - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - amount DECIMAL(10, 2) NOT NULL, - currencyFk INT NOT NULL, - pending DECIMAL(10, 2) DEFAULT 0, - balance DECIMAL(10, 2) DEFAULT 0, - endingBalance DECIMAL(10, 2) DEFAULT 0, - isPayment BOOLEAN, - isReconciled BOOLEAN, - PRIMARY KEY (id), - INDEX (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; + CREATE TEMPORARY TABLE tPendingDuedates ( + id INT auto_increment, + expirationId INT, + dated DATE, + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + amount DECIMAL(10, 2) NOT NULL, + currencyFk INT NOT NULL, + pending DECIMAL(10, 2) DEFAULT 0, + balance DECIMAL(10, 2) DEFAULT 0, + endingBalance DECIMAL(10, 2) DEFAULT 0, + isPayment BOOLEAN, + isReconciled BOOLEAN, + PRIMARY KEY (id), + INDEX (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - INSERT INTO tPendingDuedates ( - expirationId, - dated, - supplierFk, - companyFk, - amount, - currencyFk, - isPayment, - isReconciled - )SELECT p.id, - p.dueDated, - p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), - p.currencyFk, - TRUE isPayment, - p.isConciliated - FROM payment p - WHERE p.dueDated >= vStartingDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.id, - rv.dueDated, - r.supplierFk, - r.companyFk, - -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), - r.currencyFk, - FALSE isPayment, - TRUE - FROM invoiceIn r - LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk - AND r.supplierFk = si.supplierFk - AND r.currencyFk = si.currencyFk - JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE rv.dueDated >= vStartingDate - AND (si.closingBalances IS NULL OR si.closingBalances <> 0) - AND r.isBooked - AND r.companyFk = vSelf - ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; - -- Now, we calculate the outstanding amount for each receipt in descending order - SET @risk := 0.0; - SET @supplier := 0.0; - SET @company := 0.0; - SET @moneda := 0.0; - SET @pending := 0.0; - SET @day := util.VN_CURDATE(); + INSERT INTO tPendingDuedates ( + expirationId, + dated, + supplierFk, + companyFk, + amount, + currencyFk, + isPayment, + isReconciled + )SELECT p.id, + p.dueDated, + p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), + p.currencyFk, + TRUE isPayment, + p.isConciliated + FROM payment p + WHERE p.dueDated >= vStartingDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.id, + rv.dueDated, + r.supplierFk, + r.companyFk, + -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), + r.currencyFk, + FALSE isPayment, + TRUE + FROM invoiceIn r + LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk + AND r.supplierFk = si.supplierFk + AND r.currencyFk = si.currencyFk + JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE rv.dueDated >= vStartingDate + AND (si.closingBalances IS NULL OR si.closingBalances <> 0) + AND r.isBooked + AND r.companyFk = vSelf + ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; + -- Now, we calculate the outstanding amount for each receipt in descending order + SET @risk := 0.0; + SET @supplier := 0.0; + SET @company := 0.0; + SET @moneda := 0.0; + SET @pending := 0.0; + SET @day := util.VN_CURDATE(); - UPDATE tPendingDuedates vp - LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk - AND vp.supplierFk = si.supplierFk - AND vp.currencyFk = si.currencyFk - SET vp.balance = @risk := ( - IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk, - IFNULL(si.openingBalances, 0), - @risk - ) + - vp.amount - ), - -- if there is a change of company or supplier or currency, the balance is reset - vp.pending = @pending := IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk - OR @day <> vp.dated, - vp.amount * (NOT vp.isPayment), - @pending + vp.amount - ), - vp.companyFk = @company := vp.companyFk, - vp.supplierFk = @supplier := vp.supplierFk, - vp.currencyFk = @moneda := vp.currencyFk, - vp.dated = @day := vp.dated, - vp.balance = @risk, - vp.pending = @pending; + UPDATE tPendingDuedates vp + LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk + AND vp.supplierFk = si.supplierFk + AND vp.currencyFk = si.currencyFk + SET vp.balance = @risk := ( + IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk, + IFNULL(si.openingBalances, 0), + @risk + ) + + vp.amount + ), + -- if there is a change of company or supplier or currency, the balance is reset + vp.pending = @pending := IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk + OR @day <> vp.dated, + vp.amount * (NOT vp.isPayment), + @pending + vp.amount + ), + vp.companyFk = @company := vp.companyFk, + vp.supplierFk = @supplier := vp.supplierFk, + vp.currencyFk = @moneda := vp.currencyFk, + vp.dated = @day := vp.dated, + vp.balance = @risk, + vp.pending = @pending; - CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY - SELECT expirationId, - dated, - supplierFk, - companyFk, - currencyFk, - balance - FROM tPendingDuedates - WHERE balance < vInvalidBalances - AND balance > - vInvalidBalances; + CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY + SELECT expirationId, + dated, + supplierFk, + companyFk, + currencyFk, + balance + FROM tPendingDuedates + WHERE balance < vInvalidBalances + AND balance > - vInvalidBalances; - DELETE vp.* - FROM tPendingDuedates vp - JOIN tRowsToDelete rd ON ( - vp.dated < rd.dated - OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) - ) - AND vp.supplierFk = rd.supplierFk - AND vp.companyFk = rd.companyFk - AND vp.currencyFk = rd.currencyFk - WHERE NOT vp.isPayment; + DELETE vp.* + FROM tPendingDuedates vp + JOIN tRowsToDelete rd ON ( + vp.dated < rd.dated + OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) + ) + AND vp.supplierFk = rd.supplierFk + AND vp.companyFk = rd.companyFk + AND vp.currencyFk = rd.currencyFk + WHERE NOT vp.isPayment; - SELECT vp.expirationId, - vp.dated, - vp.supplierFk, - vp.companyFk, - vp.currencyFk, - vp.amount, - vp.pending, - vp.balance, - s.payMethodFk, - vp.isPayment, - vp.isReconciled, - vp.endingBalance, - cr.amount clientRiskAmount, - co.CEE - FROM tPendingDuedates vp - LEFT JOIN supplier s ON s.id = vp.supplierFk - LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk - AND cr.companyFk = vp.companyFk; + SELECT vp.expirationId, + vp.dated, + vp.supplierFk, + vp.companyFk, + vp.currencyFk, + vp.amount, + vp.pending, + vp.balance, + s.payMethodFk, + vp.isPayment, + vp.isReconciled, + vp.endingBalance, + cr.amount clientRiskAmount, + co.CEE + FROM tPendingDuedates vp + LEFT JOIN supplier s ON s.id = vp.supplierFk + LEFT JOIN client c ON c.fi = s.nif + JOIN clientRisk cr ON cr.clientFk = c.id + AND cr.companyFk = vp.companyFk + LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id + LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk + LEFT JOIN country co ON co.id = be.countryFk; - DROP TEMPORARY TABLE tOpeningBalances; - DROP TEMPORARY TABLE tPendingDuedates; - DROP TEMPORARY TABLE tRowsToDelete; + DROP TEMPORARY TABLE tOpeningBalances; + DROP TEMPORARY TABLE tPendingDuedates; + DROP TEMPORARY TABLE tRowsToDelete; END$$ DELIMITER ; From d5cb52cb6459777cb5cedb0e44ce77b3bc747674 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 10:03:01 +0200 Subject: [PATCH 087/152] feat(salix): refs #6930 Undo rollback salix-front --- front/core/services/auth.js | 3 +-- front/core/services/token.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index d77966aca..753bc3fba 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -86,8 +86,7 @@ export default class Auth { return this.$http.get('VnUsers/ShareToken', { headers: {Authorization: json.data.token} }).then(({data}) => { - // Usar data.multimediaToken.id cuando el resto de sistemas lo tengan completado - this.vnToken.set(json.data.token, json.data.token, now, json.data.ttl, remember); + this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); this.loadAcls().then(() => { let continueHash = this.$state.params.continue; if (continueHash) diff --git a/front/core/services/token.js b/front/core/services/token.js index 028ebd841..125de6b9a 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -59,8 +59,7 @@ export default class Token { getStorage(storage) { this.token = storage.getItem('vnToken'); - // Cambio realizado temporalmente - this.tokenMultimedia = this.token; // storage.getItem('vnTokenMultimedia'); + this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); From cffc1964b64adcf8575aa5a567fec4477fbe8e75 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 10:26:21 +0200 Subject: [PATCH 088/152] feat: refs #6968 Transactioned and isTriggerDisabled --- .../10997-crimsonCyca/00-groupingMode.sql | 16 ++++++++++++++++ db/versions/10997-crimsonCyca/00-part1.sql | 2 -- db/versions/10997-crimsonCyca/01-part2.sql | 7 ------- db/versions/10997-crimsonCyca/02-part3.sql | 2 -- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-groupingMode.sql delete mode 100644 db/versions/10997-crimsonCyca/00-part1.sql delete mode 100644 db/versions/10997-crimsonCyca/01-part2.sql delete mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/versions/10997-crimsonCyca/00-groupingMode.sql b/db/versions/10997-crimsonCyca/00-groupingMode.sql new file mode 100644 index 000000000..dd4896cc1 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-groupingMode.sql @@ -0,0 +1,16 @@ +START TRANSACTION; + +SET @isTriggerDisabled = TRUE; + +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; + +UPDATE vn.buy SET groupingMode2 = 'packing' WHERE groupingMode = 2; +UPDATE vn.buy SET groupingMode2 = 'grouping' WHERE groupingMode = 1; + +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; + +SET @isTriggerDisabled = FALSE; + +COMMIT; \ No newline at end of file diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql deleted file mode 100644 index 8811b81a7..000000000 --- a/db/versions/10997-crimsonCyca/00-part1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql deleted file mode 100644 index 1f7a3c9f6..000000000 --- a/db/versions/10997-crimsonCyca/01-part2.sql +++ /dev/null @@ -1,7 +0,0 @@ -UPDATE vn.buy - SET groupingMode2 = 'packing' - WHERE groupingMode = 2; - -UPDATE vn.buy - SET groupingMode2 = 'grouping' - WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql deleted file mode 100644 index c63560957..000000000 --- a/db/versions/10997-crimsonCyca/02-part3.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy DROP COLUMN groupingMode; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; From 8ca278b5a9c64572234178a459b35d35d827fc42 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 11:00:00 +0200 Subject: [PATCH 089/152] feat: refs #6500 cambios solicitados --- db/routines/vn/procedures/rateView.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 153e3584a..69e429c37 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -7,10 +7,10 @@ BEGIN SELECT t.year, t.month, - pagos.dollars, - pagos.changePractical, + pay.dollars, + pay.changePractical, CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, - pagos.changeOfficial + pay.changeOfficial FROM invoiceIn ii JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk @@ -28,7 +28,7 @@ BEGIN WHERE p.divisa AND c.code = 'USD' GROUP BY t.year, t.month - ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH + ) pay ON t.year = pay.year AND t.month = pay.month JOIN currency c ON c.id = ii.currencyFk WHERE c.code = 'USD' AND iit.foreignValue From d93dc287286dc60b51b5cc705c9a33c98fe432e6 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 17 Apr 2024 12:32:33 +0200 Subject: [PATCH 090/152] fix(view): refs #6372 fix --- db/routines/vn2008/views/gastos_resumen.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn2008/views/gastos_resumen.sql b/db/routines/vn2008/views/gastos_resumen.sql index 02231bcbf..d40d6d229 100644 --- a/db/routines/vn2008/views/gastos_resumen.sql +++ b/db/routines/vn2008/views/gastos_resumen.sql @@ -2,6 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`gastos_resumen` AS SELECT + `es`.`id` AS `id`, `es`.`expenseFk` AS `Id_Gasto`, `es`.`year` AS `year`, `es`.`month` AS `month`, From e769081a7469ebe9985dd89adceea693c2720fe5 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 13:11:28 +0200 Subject: [PATCH 091/152] feat: refs #6500 --- db/routines/vn/procedures/rateView.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 69e429c37..d840aa9d5 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -5,12 +5,12 @@ BEGIN * Muestra información sobre tasas de cambio de Dolares */ SELECT - t.year, - t.month, - pay.dollars, - pay.changePractical, - CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, - pay.changeOfficial + t.year año, + t.month mes, + pay.dollars dolares, + pay.changePractical cambioPractico, + CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4))cambioTeorico, + pay.changeOfficial cambioOficial FROM invoiceIn ii JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk From ae326e6e2edaa7f6db264266e69b9878173e6c03 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Apr 2024 13:21:27 +0200 Subject: [PATCH 092/152] 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 093/152] 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 094/152] 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 b83e0a4ae21e1c72711a0a6e1315fdef5a66977d Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 17 Apr 2024 16:43:17 +0200 Subject: [PATCH 095/152] fix: refs #6492 castToInt --- .../accountReconciliation_beforeInsert.sql | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql index c586dc57e..4fedd62b8 100644 --- a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql +++ b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql @@ -3,13 +3,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`accountReconciliation BEFORE INSERT ON `accountReconciliation` FOR EACH ROW - SET NEW.calculatedCode = REPLACE( - REPLACE( - REPLACE( - REPLACE( - CONCAT(NEW.supplierAccountFk,NEW.operationDated,NEW.amount,NEW.concept,NEW.debitCredit) - ,' ','') - ,":",'') - ,'-','') - ,'.','')$$ -DELIMITER ; + SET NEW.calculatedCode = REGEXP_REPLACE( + CONCAT(NEW.supplierAccountFk, + NEW.operationDated, + NEW.amount, + NEW.concept, + CAST(NEW.debitCredit AS UNSIGNED) + ), + '[ :\\-.]', '' + )$$ +DELIMITER ; \ No newline at end of file From f41177643f8a795e25562954e2d3d0b1ff4d93c3 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 18 Apr 2024 08:01:16 +0200 Subject: [PATCH 096/152] 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 d42aab346fa5021917f86ff4c72f66b256f7a744 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 18 Apr 2024 08:17:43 +0200 Subject: [PATCH 097/152] refactor: refs #7139 replace warehouse with ticket --- modules/route/front/summary/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 56f7a49b9..8269bf118 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -81,7 +81,7 @@ City PC Client - Warehouse + State Packages Packaging @@ -109,7 +109,7 @@ {{ticket.nickname}} - {{ticket.warehouseName}} + {{ticket.ticketStateName}} {{ticket.packages}} {{ticket.volume}} {{ticket.ipt}} From e53f1092f491ec95814e8895c20163e5d156de4e Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 08:39:10 +0200 Subject: [PATCH 098/152] fix: enable debug --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 821316c87..d700ce1f9 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' // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" From af06ef30d49bc40dcf9b9ee9956a565222465d09 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 08:50:17 +0200 Subject: [PATCH 099/152] hotFix(workerDms): document.isDocuware --- modules/worker/front/dms/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index e4cec8002..310fb95d1 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -54,7 +54,7 @@ + ng-click="$ctrl.downloadFile(document.dmsFk, document.isDocuware)"> {{::document.dms.file}} From 7a021c9ac6f804cc120542b65d7461283d516569 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 09:13:15 +0200 Subject: [PATCH 100/152] fix(payrollCenter): refs #6738 --- db/routines/vn/views/payrollCenter.sql | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/views/payrollCenter.sql b/db/routines/vn/views/payrollCenter.sql index fc6635483..dfe7e4728 100644 --- a/db/routines/vn/views/payrollCenter.sql +++ b/db/routines/vn/views/payrollCenter.sql @@ -1,12 +1,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`payrollCenter` -AS SELECT `b`.`cod_centro` AS `codCenter`, - `b`.`Centro` AS `name`, - `b`.`nss_cotizacion` AS `nss`, - `b`.`domicilio` AS `street`, - `b`.`poblacion` AS `city`, - `b`.`cp` AS `postcode`, - `b`.`empresa_id` AS `companyFk`, - `b`.`codempresa` AS `companyCode` -FROM `vn2008`.`payroll_centros` `b` +AS SELECT `b`.`workCenterFkA3` AS `codCenter`, + `b`.`companyFkA3` AS `companyCode` +FROM `vn`.`payrollWorkCenter` `b` + From 659adfd87d43b69133c34a01bee7525297e8747d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 09:20:47 +0200 Subject: [PATCH 101/152] deploy: refs #7226 dump --- db/dump/.dump/data.sql | 36 +- db/dump/.dump/privileges.sql | 47 +- db/dump/.dump/structure.sql | 1363 ++++++++++++++++++++-------------- db/dump/.dump/triggers.sql | 2 +- 4 files changed, 862 insertions(+), 586 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 8b6a01c61..8c6794a5b 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -3,7 +3,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','10970','273507d3b711f272078e83880802d0ef7278d062','2024-04-05 10:33:29','10983'); +INSERT INTO `version` VALUES ('vn-database','10977','7a021c9ac6f804cc120542b65d7461283d516569','2024-04-18 09:13:43','11000'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -703,6 +703,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10896','25-warehouse_pickup.sql' INSERT INTO `versionLog` VALUES ('vn-database','10896','29-kk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10896','30-permissions.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10898','00-table.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10900','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:50',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10903','00-professionalCategoryAddCode.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-23 08:38:28',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10905','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10906','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:04',NULL,NULL); @@ -712,6 +713,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10912','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','10913','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10914','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-28 11:52:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10915','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10917','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10918','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10919','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10922','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-29 13:44:58',NULL,NULL); @@ -722,12 +724,24 @@ INSERT INTO `versionLog` VALUES ('vn-database','10925','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','10926','00-refactorClaimState.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10928','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10929','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:16:19',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','01-Tramos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','02-dock.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','03-Proveedores_cargueras.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','04-payroll_employee.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','05-payroll_centros.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','06-payroll_conceptos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10930','07-Permisos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10932','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10940','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-06 16:48:18',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10941','00-restoreVn2008Jerarquia.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-07 09:36:57',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10942','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 10:24:45',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10943','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-07 10:29:57',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10946','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-08 07:56:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10948','00-addReconciliationConfig.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10948','02-grantPrivileges.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10948','03-modifyColumn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10949','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','00-account.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','01-bs.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','02-edi.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL); @@ -743,11 +757,18 @@ INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10962','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-25 08:27:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10964','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10967','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10968','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10969','00-aclSupplierDms.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10970','00-specialPrice.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10971','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10973','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10975','00-action.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-03 12:03:46',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10975','01-expeditionFk.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-03 12:04:52',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10976','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1108,6 +1129,7 @@ INSERT INTO `roleInherit` VALUES (359,129,35,NULL); INSERT INTO `roleInherit` VALUES (360,101,129,NULL); INSERT INTO `roleInherit` VALUES (361,50,112,NULL); INSERT INTO `roleInherit` VALUES (362,122,15,NULL); +INSERT INTO `roleInherit` VALUES (364,35,18,NULL); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -1799,7 +1821,6 @@ INSERT INTO `ACL` VALUES (799,'Ticket','saveCmr','*','ALLOW','ROLE','developer') INSERT INTO `ACL` VALUES (800,'EntryDms','*','*','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (801,'MailAliasAccount','create','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (802,'MailAliasAccount','deleteById','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (803,'ExpeditionPallet','*','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (804,'DeviceProduction','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (805,'Collection','assign','WRITE','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (806,'ExpeditionPallet','getPallet','READ','ALLOW','ROLE','production'); @@ -1808,18 +1829,19 @@ INSERT INTO `ACL` VALUES (808,'MobileAppVersionControl','getVersion','READ','ALL INSERT INTO `ACL` VALUES (809,'SaleTracking','delete','WRITE','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (810,'SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (811,'SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (812,'ExpeditionPallet','*','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (813,'Sale','getFromSectorCollection','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (814,'ItemBarcode','delete','WRITE','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (815,'WorkerActivityType','*','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (816,'WorkerActivity','*','*','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (817,'ParkingLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (818,'ExpeditionPallet','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (818,'ExpeditionPallet','*','*','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (819,'Ticket','addSaleByCode','WRITE','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (820,'TicketCollection','*','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (821,'Ticket','clone','WRITE','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (822,'SupplierDms','*','*','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (823,'MailAlias','*','*','ALLOW','ROLE','developerBoss'); +INSERT INTO `ACL` VALUES (824,'ItemShelving','hasItemOlder','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (825,'Application','getEnumValues','*','ALLOW','ROLE','employee'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2181,11 +2203,11 @@ INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0 INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO MIRIAM MAR',57,58,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'francia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); +INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 491459986..d63ce9707 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -78,7 +78,7 @@ INSERT IGNORE INTO `db` VALUES ('','bi','developer','Y','Y','Y','Y','N','N','N' INSERT IGNORE INTO `db` VALUES ('','util','grafana','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); INSERT IGNORE INTO `db` VALUES ('','mysql','developerBoss','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); INSERT IGNORE INTO `db` VALUES ('','rfid','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','floranet','floranet','N','N','N','N','N','N','N','N','N','N','Y','Y','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','floranet','floranet','Y','N','N','N','N','N','N','N','N','N','Y','Y','N','N','N','N','Y','N','N','N'); /*!40000 ALTER TABLE `db` ENABLE KEYS */; /*!40000 ALTER TABLE `tables_priv` DISABLE KEYS */; @@ -337,8 +337,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','state',' INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','travel','alexm@%','0000-00-00 00:00:00','Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Bancos_poliza','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','edi_bucket_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','edi_bucket','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','duaDismissed','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','edi_article','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','edi_bucket','alexm@%','0000-00-00 00:00:00','Select',''); @@ -349,7 +347,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payment','al INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','travel','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tramos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tramos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Trabajadores','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','empresa','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -431,12 +429,12 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Paises','alexm INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesAssistant','clientDied','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_categorias','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_centros','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_conceptos','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_centros','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_conceptos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Tintas','juan@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','alertLevel','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_employee','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_employee','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyMode','alexm@%','0000-00-00 00:00:00','Select',''); @@ -455,7 +453,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_tipo INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_codigo','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','pago','alexm@%','0000-00-00 00:00:00','Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Proveedores','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_cargueras','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_cargueras','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -779,7 +777,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','PreciosEspecia INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','movingState','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferType','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicle','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','buffer','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferGroup','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','lastRFID','alexm@%','0000-00-00 00:00:00','Select',''); @@ -858,7 +855,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleParking__','al INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','property','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','config','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleEvent','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicle','alexm@%','0000-00-00 00:00:00','Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','lastIndicators','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleComponent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); @@ -951,8 +947,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleInvoice INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleDms','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicle','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','vehicle','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicle','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Agencias','alexm@%','0000-00-00 00:00:00','Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1215,7 +1210,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','m3','juan@db-proxy2 INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cajas','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','tagAbbreviation','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemImageQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','parking','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketing','parking','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sectorCollection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplier','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1379,6 +1374,20 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState', INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimRatio','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneIncluded','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','quality','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','category','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','edi_bucket_type','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektEntryAssign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','edi_bucket','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','timeSlots','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierFreight','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorker','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorkCenter','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; @@ -1648,7 +1657,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','getinventoryDate INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','zone_upcomingdeliveries','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','vn_now','FUNCTION','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_unlock','PROCEDURE','guillermo@10.5.1.4','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','agency','agencia_volume','PROCEDURE','root@10.1.4.166','Execute','2022-08-03 23:44:43'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','zone_getAgency','PROCEDURE','juan@77.228.249.89','Execute','2022-08-03 23:44:43'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','invoiceout_getpath','FUNCTION','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','employee','order_confirm','PROCEDURE','z-developer@www1.static.verdnatura.es','Execute','2022-08-03 23:44:43'); @@ -1662,7 +1670,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_hasRoleId' INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_checkLogin','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','lang','FUNCTION','juan@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofmonth','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','financial','account_conciliacion_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','addAccountReconciliation','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_moveNotPrinted','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -1717,6 +1725,8 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaInvoiceInB INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvinglog_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','client_getDebt','FUNCTION','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_commit','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','hrBoss','balance_create','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -1795,6 +1805,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','zone_getstate','PRO INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_gethierarchy','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','workertimecontrol_weekcheckbreak','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_split','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','agency','agencyVolume','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','saletracking_new','PROCEDURE','alexm@pc325.algemesi.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticketnotinvoicedbyclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -2027,7 +2038,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','account','{\"access\": 0, \"is_rol INSERT IGNORE INTO `global_priv` VALUES ('','adminBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','adminOfficer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); INSERT IGNORE INTO `global_priv` VALUES ('','administrative','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','agency','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 20000, \"max_user_connections\": 50, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','agency','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 20000, \"max_user_connections\": 50, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":101106}'); INSERT IGNORE INTO `global_priv` VALUES ('','android','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','artificialBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','assetManager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); @@ -2068,8 +2079,8 @@ INSERT IGNORE INTO `global_priv` VALUES ('','maintenance','{\"access\":0,\"vers INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBos','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','manager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','officeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','packager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','palletizer','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 023a997d3..4812b536b 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -2147,7 +2147,7 @@ BEGIN * The user name must only contain lowercase letters or, starting with second * character, numbers or underscores. */ - IF vUserName NOT REGEXP '^[a-z0-9_-]*$' THEN + IF vUserName NOT REGEXP BINARY '^[a-z0-9_-]+$' THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'INVALID_USER_NAME'; END IF; @@ -3738,8 +3738,19 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `greuge_dif_porte_add`() BEGIN - DECLARE datSTART DATETIME DEFAULT TIMESTAMPADD(DAY,-60,util.VN_CURDATE()); -- '2019-07-01' - DECLARE datEND DATETIME DEFAULT TIMESTAMPADD(DAY,-1,util.VN_CURDATE()); + +/** + * Calculates the greuge based on a specific date in the 'grievanceConfig' table + */ + + DECLARE vDateStarted DATETIME; + DECLARE vDateEnded DATETIME DEFAULT (util.VN_CURDATE() - INTERVAL 1 DAY); + DECLARE vDaysAgoOffset INT; + + SELECT daysAgoOffset INTO vDaysAgoOffset + FROM vn.greugeConfig; + + SET vDateStarted = util.VN_CURDATE() - INTERVAL vDaysAgoOffset DAY; DROP TEMPORARY TABLE IF EXISTS tmp.dp; @@ -3747,53 +3758,53 @@ BEGIN CREATE TEMPORARY TABLE tmp.dp (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - SELECT t.id ticketFk, - SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) AS teorico, - 00000.00 as practico, - 00000.00 as greuge, - t.clientFk, - t.shipped - FROM - vn.ticket t - JOIN vn2008.Clientes cli ON cli.Id_cliente = t.clientFk - LEFT JOIN vn.expedition e ON e.ticketFk = t.id - JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk - JOIN vn.zone z ON t.zoneFk = z.id - WHERE - t.shipped between datSTART AND datEND - AND cli.`real` - AND t.companyFk IN (442 , 567) - AND z.isVolumetric = FALSE - GROUP BY t.id; + SELECT t.id ticketFk, + SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) teorico, + 00000.00 practico, + 00000.00 greuge, + t.clientFk, + t.shipped + FROM vn.ticket t + JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.expedition e ON e.ticketFk = t.id + JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk + JOIN vn.zone z ON t.zoneFk = z.id + JOIN vn.company cp ON cp.id = t.companyFk + WHERE t.shipped BETWEEN vDateStarted AND vDateEnded + AND c.isRelevant + AND cp.code IN ('VNL', 'VNH') + AND NOT z.isVolumetric + GROUP BY t.id; -- Agencias que cobran por volumen INSERT INTO tmp.dp SELECT sv.ticketFk, - SUM(IFNULL(sv.freight,0)) AS teorico, - 00000.00 as practico, - 00000.00 as greuge, - sv.clientFk, - sv.shipped - FROM vn.saleVolume sv - JOIN vn.zone z ON z.id = sv.zoneFk - AND sv.shipped BETWEEN datSTART AND datEND - AND z.isVolumetric != FALSE - GROUP BY sv.ticketFk; + SUM(IFNULL(sv.freight,0)) teorico, + 00000.00 practico, + 00000.00 greuge, + sv.clientFk, + sv.shipped + FROM vn.saleVolume sv + JOIN vn.zone z ON z.id = sv.zoneFk + AND sv.shipped BETWEEN vDateStarted AND vDateEnded + AND z.isVolumetric != FALSE + GROUP BY sv.ticketFk; DROP TEMPORARY TABLE IF EXISTS tmp.dp_aux; CREATE TEMPORARY TABLE tmp.dp_aux (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - SELECT dp.ticketFk, sum(Cantidad * Valor) as valor - FROM tmp.dp - JOIN vn2008.Movimientos m ON m.Id_Ticket = dp.ticketFk - JOIN vn2008.Movimientos_componentes mc using(Id_Movimiento) - WHERE mc.Id_Componente = 15 - GROUP BY dp.ticketFk; + SELECT dp.ticketFk, SUM(s.quantity * sc.value) valor + FROM tmp.dp + JOIN vn.sale s ON s.ticketFk = dp.ticketFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.component c ON c.id = sc.componentFk + WHERE c.code = 'delivery' + GROUP BY dp.ticketFk; UPDATE tmp.dp - JOIN tmp.dp_aux USING(ticketFk) + JOIN tmp.dp_aux USING(ticketFk) SET practico = IFNULL(valor,0); DROP TEMPORARY TABLE tmp.dp_aux; @@ -3801,28 +3812,29 @@ BEGIN CREATE TEMPORARY TABLE tmp.dp_aux (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - SELECT dp.ticketFk, sum(g.amount) Importe + SELECT dp.ticketFk, SUM(g.amount) Importe FROM tmp.dp - JOIN vn.greuge g ON g.ticketFk = dp.ticketFk - WHERE g.greugeTypeFk = 1 -- dif_porte - GROUP BY dp.ticketFk; + JOIN vn.greuge g ON g.ticketFk = dp.ticketFk + JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk + WHERE gt.code = 'freightDifference' -- dif_porte + GROUP BY dp.ticketFk; UPDATE tmp.dp - JOIN tmp.dp_aux USING(ticketFk) + JOIN tmp.dp_aux USING(ticketFk) SET greuge = IFNULL(Importe,0); INSERT INTO vn.greuge (clientFk,description,amount,shipped,greugeTypeFk,ticketFk) - SELECT dp.clientFk - , concat('dif_porte ', dp.ticketFk) - , round(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) as Importe - , date(dp.shipped) - , 1 - ,dp.ticketFk + SELECT dp.clientFk, + CONCAT('dif_porte ', dp.ticketFk), + ROUND(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) Importe, + date(dp.shipped), + 1, + dp.ticketFk FROM tmp.dp - JOIN vn.client c ON c.id = dp.clientFk + JOIN vn.client c ON c.id = dp.clientFk WHERE ABS(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0)) > 1 AND c.isRelevant; - + DROP TEMPORARY TABLE tmp.dp, tmp.dp_aux; @@ -10536,7 +10548,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, + @pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, @@ -11918,7 +11930,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalogue_get`(vLanded DATE, vPostalCode VARCHAR(15)) READS SQL DATA -BEGIN +proc:BEGIN /** * Returns list, price and all the stuff regarding the floranet items * @@ -11926,10 +11938,22 @@ BEGIN * @param vPostalCode Delivery address postal code */ DECLARE vLastCatalogueFk INT; + DECLARE vLockName VARCHAR(20); + DECLARE vLockTime INT; - START TRANSACTION; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK(vLockName); - SELECT * FROM catalogue FOR UPDATE; + RESIGNAL; + END; + + SET vLockName = 'catalogue_get'; + SET vLockTime = 15; + + IF NOT GET_LOCK(vLockName, vLockTime) THEN + LEAVE proc; + END IF; SELECT MAX(id) INTO vLastCatalogueFk FROM catalogue; @@ -11960,7 +11984,7 @@ BEGIN FROM catalogue WHERE id > IFNULL(vLastCatalogueFk,0); - COMMIT; + DO RELEASE_LOCK(vLockName); END ;; DELIMITER ; @@ -12142,7 +12166,8 @@ BEGIN i.longName FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP'); + WHERE it.code IN ('FNR','FNP') + LIMIT 3; END ;; DELIMITER ; @@ -13345,14 +13370,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE ENABLE DO CALL order_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE DISABLE DO CALL order_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -15699,7 +15724,8 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO orderRecalc SET orderFk = vSelf; + -- #4409 Disable order recalc + -- INSERT INTO orderRecalc SET orderFk = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -16566,8 +16592,7 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL, - `sundayFestive` tinyint(4) NOT NULL, - `countryPrefix` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `defaultPrefix` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `config_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration'; @@ -16638,6 +16663,36 @@ SET character_set_client = utf8; 1 AS `timeout` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `holiday` +-- + +DROP TABLE IF EXISTS `holiday`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `holiday` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `country` char(2) NOT NULL, + `day` date NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `holiday_country_IDX` (`country`,`day`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `prefix` +-- + +DROP TABLE IF EXISTS `prefix`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `prefix` ( + `country` char(2) NOT NULL COMMENT 'Country code', + `prefix` varchar(100) NOT NULL COMMENT 'Country prefix', + PRIMARY KEY (`country`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `queue` -- @@ -16755,13 +16810,11 @@ DROP TABLE IF EXISTS `schedule`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `schedule` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `weekDay` tinyint(3) unsigned NOT NULL COMMENT '0 = Monday, 6 = Sunday', - `timeStart` time NOT NULL, - `timeEnd` time NOT NULL, - `queue` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `queue` (`queue`), - CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`) + `weekDays` set('mon','tue','wed','thu','fri','sat','sun') NOT NULL COMMENT '0 = Monday, 6 = Sunday', + `startTime` time NOT NULL, + `endTime` time NOT NULL, + `country` char(2) NOT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26644,16 +26697,24 @@ BEGIN */ DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log; DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin; + DECLARE vLogExists BOOL; SET sql_log_bin = OFF; SET GLOBAL slow_query_log = OFF; - RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + SELECT COUNT(*) > 0 INTO vLogExists + FROM information_schema.TABLES + WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log'; - DELETE FROM `mysql`.`slow_log_temp` + IF vLogExists THEN + DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp; + RENAME TABLE mysql.slow_log TO mysql.slow_log_temp; + END IF; + + DELETE FROM mysql.slow_log_temp WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); - RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; + RENAME TABLE mysql.slow_log_temp TO mysql.slow_log; SET GLOBAL slow_query_log = vSlowQueryLog; SET sql_log_bin = vSqlLogBin; @@ -27002,7 +27063,7 @@ CREATE TABLE `accountReconciliation` ( `valueDated` datetime NOT NULL, `amount` double NOT NULL, `concept` varchar(255) DEFAULT NULL, - `debitCredit` smallint(6) NOT NULL, + `debitCredit` enum('debit','credit') DEFAULT NULL, `calculatedCode` varchar(255) DEFAULT NULL, `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), @@ -27013,6 +27074,25 @@ CREATE TABLE `accountReconciliation` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `accountReconciliationConfig` +-- + +DROP TABLE IF EXISTS `accountReconciliationConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `accountReconciliationConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `currencyFk` tinyint(3) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `account_fk_currency` (`currencyFk`), + KEY `account_fk_warehouse` (`warehouseFk`), + CONSTRAINT `account_fk_currency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`), + CONSTRAINT `account_fk_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `accounting` -- @@ -28233,7 +28313,6 @@ CREATE TABLE `buy` ( `deliveryFk` int(11) DEFAULT NULL, `itemOriginalFk` int(11) DEFAULT NULL COMMENT 'Item original de la entrada', `editorFk` int(10) unsigned DEFAULT NULL, - `packageFk` varchar(10) GENERATED ALWAYS AS (`packagingFk`) VIRTUAL, `buyerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `CompresId_Trabajador` (`workerFk`), @@ -28522,7 +28601,7 @@ CREATE TABLE `claim` ( `isChargedToMana` tinyint(1) NOT NULL DEFAULT 0, `created` timestamp NULL DEFAULT current_timestamp(), `ticketFk` int(11) DEFAULT NULL, - `hasToPickUp` tinyint(1) NOT NULL, + `pickup` enum('agency','delivery') DEFAULT NULL, `packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client', `rma__` varchar(100) DEFAULT NULL, `responsabilityRate` decimal(3,2) GENERATED ALWAYS AS ((5 - `responsibility`) / 4) VIRTUAL, @@ -31138,7 +31217,7 @@ CREATE TABLE `entry` ( `companyFk` int(10) unsigned NOT NULL DEFAULT 442, `gestDocFk` int(11) DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isBlocked` tinyint(4) NOT NULL DEFAULT 0, + `isBlocked__` tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 27/03/2024', `loadPriority` int(11) DEFAULT NULL, `kop` int(11) DEFAULT NULL, `sub` mediumint(8) unsigned DEFAULT NULL, @@ -32146,7 +32225,9 @@ CREATE TABLE `flight` ( `airlineFk` smallint(2) unsigned DEFAULT NULL, `airportArrivalFk` varchar(3) NOT NULL, `airportDepartureFk` varchar(3) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `flight_airline_FK` (`airlineFk`), + CONSTRAINT `flight_airline_FK` FOREIGN KEY (`airlineFk`) REFERENCES `airline` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32397,6 +32478,7 @@ CREATE TABLE `greugeConfig` ( `yearsToDelete` int(11) DEFAULT NULL, `maxPercentToWrong` decimal(10,2) DEFAULT NULL COMMENT 'Porcentaje del precio del ticket que es considerado error', `lastNotifyCheck` timestamp NULL DEFAULT NULL COMMENT 'Última ejecución del procedimiento que revisa los greuges anormales', + `daysAgoOffset` int(11) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `greugeConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -35692,15 +35774,72 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `payrollCenter` AS SELECT 1 AS `codCenter`, - 1 AS `name`, - 1 AS `nss`, - 1 AS `street`, - 1 AS `city`, - 1 AS `postcode`, - 1 AS `companyFk`, 1 AS `companyCode` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `payrollComponent` +-- + +DROP TABLE IF EXISTS `payrollComponent`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `payrollComponent` ( + `id` int(11) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `isSalaryAgreed` tinyint(1) NOT NULL DEFAULT 0, + `isVariable` tinyint(1) NOT NULL, + `isException` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Excepciones a tener en cuenta al importar conceptos en el proceso de importación de ficheros A3.', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `payrollWorkCenter` +-- + +DROP TABLE IF EXISTS `payrollWorkCenter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `payrollWorkCenter` ( + `workCenterFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.', + `Centro__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `domicilio__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `poblacion__` varchar(45) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `cp__` varchar(5) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `empresa_id__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `companyFkA3` int(11) DEFAULT NULL COMMENT 'Columna que hace referencia a A3.', + PRIMARY KEY (`workCenterFkA3`,`empresa_id__`), + KEY `payroll_centros_ix1` (`empresa_id__`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `payrollWorker` +-- + +DROP TABLE IF EXISTS `payrollWorker`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `payrollWorker` ( + `workerFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.', + `nss__` varchar(23) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `codpuesto__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `companyFkA3` int(10) NOT NULL COMMENT 'Columna que hace referencia a A3.', + `codcontrato__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `FAntiguedad__` date NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `grupotarifa__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `codcategoria__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@Deprecated refs #6738 15/03/2024', + `workerFk` int(11) unsigned DEFAULT NULL, + PRIMARY KEY (`workerFkA3`,`companyFkA3`), + KEY `sajvgfh_idx` (`codpuesto__`), + KEY `payroll_employee_workerFk_idx` (`workerFk`), + CONSTRAINT `payroll_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `pcs` -- @@ -36258,6 +36397,7 @@ CREATE TABLE `productionConfig` ( `clientSelfConsumptionFk` int(11) DEFAULT NULL COMMENT 'Cliente para crear el ticket de autoconsumo', `itemPreviousDefaultSize` int(11) DEFAULT NULL COMMENT 'Altura por defecto para los artículos de previa', `addressSelfConsumptionFk` int(11) DEFAULT 2613 COMMENT 'Consignatario para crear el ticket de autoconsumo', + `defaultFreightItemFk` int(10) unsigned NOT NULL DEFAULT 71 COMMENT 'Default value for expedition table', PRIMARY KEY (`id`), KEY `productionConfig_FK` (`shortageAddressFk`), KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`), @@ -38667,7 +38807,7 @@ CREATE TABLE `supplier` ( `payDay` tinyint(4) unsigned DEFAULT NULL, `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7, `created` timestamp NOT NULL DEFAULT current_timestamp(), - `isSerious` tinyint(1) unsigned NOT NULL DEFAULT 0, + `isReal` tinyint(1) unsigned NOT NULL DEFAULT 0, `note` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `postcodeFk` int(11) unsigned DEFAULT NULL, `postCode` char(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, @@ -38901,6 +39041,20 @@ CREATE TABLE `supplierExpense` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `supplierFreight` +-- + +DROP TABLE IF EXISTS `supplierFreight`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `supplierFreight` ( + `supplierFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`supplierFk`), + CONSTRAINT `Proveedores_cargueras_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de espcializacion para señalar las compañias que prestan servicio de transitario'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `supplierLog` -- @@ -40078,6 +40232,21 @@ CREATE TABLE `time` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de referencia para las semanas, años y meses'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `timeSlots` +-- + +DROP TABLE IF EXISTS `timeSlots`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `timeSlots` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `section` time NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `Tramo` (`section`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `town` -- @@ -41370,7 +41539,7 @@ CREATE TABLE `workerIncome` ( PRIMARY KEY (`id`), KEY `income_employeeId_incomeType_idx` (`incomeTypeFk`), KEY `income_employee_workerFk_idx` (`workerFk`), - CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`incomeTypeFk`) REFERENCES `vn2008`.`payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE, + CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`incomeTypeFk`) REFERENCES `payrollComponent` (`id`) ON UPDATE CASCADE, CONSTRAINT `income_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -47327,6 +47496,85 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `addAccountReconciliation` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `addAccountReconciliation`() +BEGIN +/** + * Updates duplicate records in the accountReconciliation table, + * by assigning them a new identifier and then inserts a new entry in the till table. + */ + UPDATE accountReconciliation ar + JOIN ( + SELECT id, + calculatedCode, + CONCAT( + calculatedCode, + '(', + ROW_NUMBER() OVER (PARTITION BY calculatedCode ORDER BY id), + ')' + ) newId + FROM accountReconciliation ar + WHERE calculatedCode IN ( + SELECT calculatedCode + FROM accountReconciliation + GROUP BY calculatedCode + HAVING COUNT(*) > 1 + ) + ORDER BY calculatedCode, id + ) sub2 ON ar.id = sub2.id + SET ar.calculatedCode = sub2.newId; + + INSERT INTO till( + dated, + isAccountable, + serie, + concept, + `in`, + `out`, + bankFk, + companyFk, + warehouseFk, + supplierAccountFk, + calculatedCode, + InForeignValue, + OutForeignValue, + workerFk + ) + SELECT ar.operationDated, + TRUE, + 'MB', + ar.concept, + IF(ar.debitCredit = 'credit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL), + IF(ar.debitCredit = 'debit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL), + a.id, + sa.supplierFk, + arc.warehouseFk, + ar.supplierAccountFk, + ar.calculatedCode, + IF(ar.debitCredit = 'credit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL), + IF(ar.debitCredit = 'debit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL), + account.myUser_getId() + FROM accountReconciliation ar + JOIN supplierAccount sa ON sa.id = ar.supplierAccountFk + JOIN accounting a ON a.id = sa.accountingFk + LEFT JOIN till t ON t.calculatedCode = ar.calculatedCode + JOIN accountReconciliationConfig arc + WHERE t.id IS NULL; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `addNoteFromDelivery` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47611,6 +47859,57 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `agencyVolume` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyVolume`() +BEGIN +/** + * Calculates and presents information on shipment and packaging volumes + * for agencies that are not owned for a specific period. + */ + DECLARE vStarted DATETIME DEFAULT util.VN_CURDATE(); + DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE()); + + SELECT ag.id agency_id, + CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia, + COUNT(*) expediciones, + SUM(t.packages) Bultos, + SUM(tpe.boxes) Faltan + FROM ticket t + JOIN warehouse w ON w.id = t.warehouseFk + JOIN country c ON w.countryFk = c.id + JOIN address a ON a.id = t.addressFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN ( + SELECT sv.ticketFk, + CEIL(1000 * SUM(sv.volume) / vc.standardFlowerBox) boxes + FROM ticket t + JOIN saleVolume sv ON sv.ticketFk = t.id + JOIN volumeConfig vc + WHERE t.shipped BETWEEN vStarted AND vEnded + AND (t.packages IS NULL OR NOT t.packages) + GROUP BY t.id + ) tpe ON tpe.ticketFk = t.id + WHERE t.shipped BETWEEN vStarted AND vEnded + AND NOT ag.isOwn + GROUP BY ag.id + ORDER BY Agencia; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52062,196 +52361,196 @@ BEGIN * @param vSelf company id * @param vMonthAgo time interval to be consulted */ - DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); - DECLARE vCurrencyEuroFk INT; - DECLARE vStartDate DATE; - DECLARE vInvalidBalances DOUBLE; + DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); + DECLARE vCurrencyEuroFk INT; + DECLARE vStartDate DATE; + DECLARE vInvalidBalances DOUBLE; - SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; - SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; + SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; + SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; - DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; - CREATE TEMPORARY TABLE tOpeningBalances ( - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - openingBalances DOUBLE NOT NULL, - closingBalances DOUBLE NOT NULL, - currencyFk INT NOT NULL, - PRIMARY KEY (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; + CREATE TEMPORARY TABLE tOpeningBalances ( + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + openingBalances DOUBLE NOT NULL, + closingBalances DOUBLE NOT NULL, + currencyFk INT NOT NULL, + PRIMARY KEY (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - -- Calculates the opening and closing balance for each supplier - INSERT INTO tOpeningBalances - SELECT supplierFk, - companyFk, - SUM(amount * isBeforeStarting) AS openingBalances, - SUM(amount) closingBalances, - currencyFk - FROM ( - SELECT p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, - p.dueDated < vStartingDate isBeforeStarting, - p.currencyFk - FROM payment p - WHERE p.received > vStartDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.supplierFk, - r.companyFk, - - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, - rv.dueDated < vStartingDate isBeforeStarting, - r.currencyFk - FROM invoiceIn r - INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE r.issued > vStartDate - AND r.isBooked - AND r.companyFk = vSelf - ) sub GROUP BY companyFk, supplierFk, currencyFk; + -- Calculates the opening and closing balance for each supplier + INSERT INTO tOpeningBalances + SELECT supplierFk, + companyFk, + SUM(amount * isBeforeStarting) AS openingBalances, + SUM(amount) closingBalances, + currencyFk + FROM ( + SELECT p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, + p.dueDated < vStartingDate isBeforeStarting, + p.currencyFk + FROM payment p + WHERE p.received > vStartDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.supplierFk, + r.companyFk, + - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, + rv.dueDated < vStartingDate isBeforeStarting, + r.currencyFk + FROM invoiceIn r + INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE r.issued > vStartDate + AND r.isBooked + AND r.companyFk = vSelf + ) sub GROUP BY companyFk, supplierFk, currencyFk; - DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; - CREATE TEMPORARY TABLE tPendingDuedates ( - id INT auto_increment, - expirationId INT, - dated DATE, - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - amount DECIMAL(10, 2) NOT NULL, - currencyFk INT NOT NULL, - pending DECIMAL(10, 2) DEFAULT 0, - balance DECIMAL(10, 2) DEFAULT 0, - endingBalance DECIMAL(10, 2) DEFAULT 0, - isPayment BOOLEAN, - isReconciled BOOLEAN, - PRIMARY KEY (id), - INDEX (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; + CREATE TEMPORARY TABLE tPendingDuedates ( + id INT auto_increment, + expirationId INT, + dated DATE, + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + amount DECIMAL(10, 2) NOT NULL, + currencyFk INT NOT NULL, + pending DECIMAL(10, 2) DEFAULT 0, + balance DECIMAL(10, 2) DEFAULT 0, + endingBalance DECIMAL(10, 2) DEFAULT 0, + isPayment BOOLEAN, + isReconciled BOOLEAN, + PRIMARY KEY (id), + INDEX (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - INSERT INTO tPendingDuedates ( - expirationId, - dated, - supplierFk, - companyFk, - amount, - currencyFk, - isPayment, - isReconciled - )SELECT p.id, - p.dueDated, - p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), - p.currencyFk, - TRUE isPayment, - p.isConciliated - FROM payment p - WHERE p.dueDated >= vStartingDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.id, - rv.dueDated, - r.supplierFk, - r.companyFk, - -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), - r.currencyFk, - FALSE isPayment, - TRUE - FROM invoiceIn r - LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk - AND r.supplierFk = si.supplierFk - AND r.currencyFk = si.currencyFk - JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE rv.dueDated >= vStartingDate - AND (si.closingBalances IS NULL OR si.closingBalances <> 0) - AND r.isBooked - AND r.companyFk = vSelf - ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; - -- Now, we calculate the outstanding amount for each receipt in descending order - SET @risk := 0.0; - SET @supplier := 0.0; - SET @company := 0.0; - SET @moneda := 0.0; - SET @pending := 0.0; - SET @day := util.VN_CURDATE(); + INSERT INTO tPendingDuedates ( + expirationId, + dated, + supplierFk, + companyFk, + amount, + currencyFk, + isPayment, + isReconciled + )SELECT p.id, + p.dueDated, + p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), + p.currencyFk, + TRUE isPayment, + p.isConciliated + FROM payment p + WHERE p.dueDated >= vStartingDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.id, + rv.dueDated, + r.supplierFk, + r.companyFk, + -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), + r.currencyFk, + FALSE isPayment, + TRUE + FROM invoiceIn r + LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk + AND r.supplierFk = si.supplierFk + AND r.currencyFk = si.currencyFk + JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE rv.dueDated >= vStartingDate + AND (si.closingBalances IS NULL OR si.closingBalances <> 0) + AND r.isBooked + AND r.companyFk = vSelf + ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; + -- Now, we calculate the outstanding amount for each receipt in descending order + SET @risk := 0.0; + SET @supplier := 0.0; + SET @company := 0.0; + SET @moneda := 0.0; + SET @pending := 0.0; + SET @day := util.VN_CURDATE(); - UPDATE tPendingDuedates vp - LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk - AND vp.supplierFk = si.supplierFk - AND vp.currencyFk = si.currencyFk - SET vp.balance = @risk := ( - IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk, - IFNULL(si.openingBalances, 0), - @risk - ) + - vp.amount - ), - -- if there is a change of company or supplier or currency, the balance is reset - vp.pending = @pending := IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk - OR @day <> vp.dated, - vp.amount * (NOT vp.isPayment), - @pending + vp.amount - ), - vp.companyFk = @company := vp.companyFk, - vp.supplierFk = @supplier := vp.supplierFk, - vp.currencyFk = @moneda := vp.currencyFk, - vp.dated = @day := vp.dated, - vp.balance = @risk, - vp.pending = @pending; + UPDATE tPendingDuedates vp + LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk + AND vp.supplierFk = si.supplierFk + AND vp.currencyFk = si.currencyFk + SET vp.balance = @risk := ( + IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk, + IFNULL(si.openingBalances, 0), + @risk + ) + + vp.amount + ), + -- if there is a change of company or supplier or currency, the balance is reset + vp.pending = @pending := IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk + OR @day <> vp.dated, + vp.amount * (NOT vp.isPayment), + @pending + vp.amount + ), + vp.companyFk = @company := vp.companyFk, + vp.supplierFk = @supplier := vp.supplierFk, + vp.currencyFk = @moneda := vp.currencyFk, + vp.dated = @day := vp.dated, + vp.balance = @risk, + vp.pending = @pending; - CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY - SELECT expirationId, - dated, - supplierFk, - companyFk, - currencyFk, - balance - FROM tPendingDuedates - WHERE balance < vInvalidBalances - AND balance > - vInvalidBalances; + CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY + SELECT expirationId, + dated, + supplierFk, + companyFk, + currencyFk, + balance + FROM tPendingDuedates + WHERE balance < vInvalidBalances + AND balance > - vInvalidBalances; - DELETE vp.* - FROM tPendingDuedates vp - JOIN tRowsToDelete rd ON ( - vp.dated < rd.dated - OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) - ) - AND vp.supplierFk = rd.supplierFk - AND vp.companyFk = rd.companyFk - AND vp.currencyFk = rd.currencyFk - WHERE NOT vp.isPayment; + DELETE vp.* + FROM tPendingDuedates vp + JOIN tRowsToDelete rd ON ( + vp.dated < rd.dated + OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) + ) + AND vp.supplierFk = rd.supplierFk + AND vp.companyFk = rd.companyFk + AND vp.currencyFk = rd.currencyFk + WHERE NOT vp.isPayment; - SELECT vp.expirationId, - vp.dated, - vp.supplierFk, - vp.companyFk, - vp.currencyFk, - vp.amount, - vp.pending, - vp.balance, - s.payMethodFk, - vp.isPayment, - vp.isReconciled, - vp.endingBalance, - cr.amount clientRiskAmount, - co.CEE - FROM tPendingDuedates vp - LEFT JOIN supplier s ON s.id = vp.supplierFk - LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk - AND cr.companyFk = vp.companyFk; + SELECT vp.expirationId, + vp.dated, + vp.supplierFk, + vp.companyFk, + vp.currencyFk, + vp.amount, + vp.pending, + vp.balance, + s.payMethodFk, + vp.isPayment, + vp.isReconciled, + vp.endingBalance, + cr.amount clientRiskAmount, + co.CEE + FROM tPendingDuedates vp + LEFT JOIN supplier s ON s.id = vp.supplierFk + LEFT JOIN client c ON c.fi = s.nif + JOIN clientRisk cr ON cr.clientFk = c.id + AND cr.companyFk = vp.companyFk + LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id + LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk + LEFT JOIN country co ON co.id = be.countryFk; - DROP TEMPORARY TABLE tOpeningBalances; - DROP TEMPORARY TABLE tPendingDuedates; - DROP TEMPORARY TABLE tRowsToDelete; + DROP TEMPORARY TABLE tOpeningBalances; + DROP TEMPORARY TABLE tPendingDuedates; + DROP TEMPORARY TABLE tRowsToDelete; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53921,7 +54220,7 @@ BEGIN FROM `entry` WHERE id = vSelf; - IF vIsBooked THEN + IF vIsBooked AND NOT @isModeInventory THEN CALL util.throw('Entry is already booked'); END IF; END ;; @@ -56585,8 +56884,6 @@ BEGIN CLOSE cWarehouses; UPDATE config SET inventoried = vInventoryDate; - - SET @isModeInventory := FALSE; CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete (INDEX(entryId)) ENGINE = MEMORY @@ -56615,6 +56912,8 @@ BEGIN FROM travel t JOIN tEntryToDelete tmp ON tmp.travelId = t.id; + SET @isModeInventory := FALSE; + DROP TEMPORARY TABLE IF EXISTS tEntryToDelete; COMMIT; @@ -58186,16 +58485,21 @@ BEGIN DELETE ti.* FROM tmp.ticketToInvoice ti JOIN ticket t ON t.id = ti.id + LEFT JOIN address a ON a.id = t.addressFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk JOIN supplier su ON su.id = t.companyFk JOIN client c ON c.id = t.clientFk - LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = su.countryFk WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted) OR c.isTaxDataChecked = FALSE OR t.isDeleted OR c.hasToInvoice = FALSE - OR itc.id IS NULL; + OR itc.id IS NULL + OR a.id IS NULL + OR (vTaxArea = 'WORLD' + AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 INTO vIsAnySaleToInvoice @@ -60030,75 +60334,78 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) -BEGIN - - -/** - * Añade registro o lo actualiza si ya existe. - * - * @param vShelvingFk matrícula del carro - * @param vBarcode el id del registro - * @param vQuantity indica la cantidad del producto - * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra - * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra - * @param vPacking el packing del producto, NULL para coger el de la ultima compra - * @param vWarehouseFk indica el sector - * - **/ - - DECLARE vItemFk INT; - - SELECT barcodeToItem(vBarcode) INTO vItemFk; - - IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); - INSERT INTO shelving(code, parkingFk) - SELECT vShelvingFk, id - FROM parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - - UPDATE itemShelving - SET visible = visible+vQuantity - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; - - ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - grouping, - packing, - packagingFk) - - SELECT vItemFk, - vShelvingFk, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk) - FROM item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; +BEGIN + + +/** + * Añade registro o lo actualiza si ya existe. + * + * @param vShelvingFk matrícula del carro + * @param vBarcode el id del registro + * @param vQuantity indica la cantidad del producto + * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra + * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra + * @param vPacking el packing del producto, NULL para coger el de la ultima compra + * @param vWarehouseFk indica el sector + * + **/ + + DECLARE vItemFk INT; + + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1)); + SET vQuantity = vQuantity * vPacking; + + IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN + + INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); + INSERT INTO shelving(code, parkingFk) + SELECT vShelvingFk, id + FROM parking + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + IF (SELECT COUNT(*) FROM itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking) = 1 THEN + + UPDATE itemShelving + SET visible = visible+vQuantity + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + + ELSE + CALL cache.last_buy_refresh(FALSE); + INSERT INTO itemShelving( itemFk, + shelvingFk, + visible, + grouping, + packing, + packagingFk) + + SELECT vItemFk, + vShelvingFk, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packagingFk) + FROM item i + LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN buy b ON b.id = lb.buy_id + WHERE i.id = vItemFk; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62423,7 +62730,11 @@ BEGIN (i.value8 <=> its.value8) match8, a.available, IFNULL(ip.counter, 0) `counter`, - IF(b.groupingMode = 1, b.grouping, b.packing) minQuantity, + CASE + WHEN b.groupingMode = 1 THEN b.grouping + WHEN b.groupingMode = 2 THEN b.packing + ELSE 1 + END AS minQuantity, iss.visible located FROM vn.item i JOIN cache.available a ON a.item_id = i.id @@ -67394,13 +67705,13 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`jenkins`@`10.0.%.%` PROCEDURE `sale_boxPickingPrint`( +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_boxPickingPrint`( IN vPrinterFk INT, IN vSaleFk INT, IN vPacking INT, IN vSectorFk INT, IN vUserFk INT, - IN vPackagingFk INT, + IN vPackagingFk VARCHAR(10), IN vPackingSiteFk INT) BEGIN /** Splits a line of sale to a different ticket and prints the transport sticker @@ -67455,6 +67766,8 @@ BEGIN w1: WHILE vQuantity >= vPacking DO + SET vQuantity = vQuantity - vPacking; + SET vItemShelvingFk = NULL; SELECT sub.id @@ -67585,7 +67898,7 @@ w1: WHILE vQuantity >= vPacking DO ELSE UPDATE itemShelvingSale SET saleFk = vNewSaleFk - WHERE id = vItemShelvingSaleFk; + WHERE id = vItemShelvingSaleFk; END IF; ELSE INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price) @@ -67603,6 +67916,7 @@ w1: WHILE vQuantity >= vPacking DO UPDATE itemShelvingSale SET saleFk = vNewSaleFk WHERE id = vItemShelvingSaleFk; + END IF; INSERT IGNORE INTO saleTracking(saleFk, isChecked, workerFk, stateFk) @@ -67629,7 +67943,7 @@ w1: WHILE vQuantity >= vPacking DO ) SELECT vAgencyModeFk, vNewTicketFk, - i.id, + pc.defaultFreightItemFk, vUserFk, vPackagingFk, ps.code, @@ -67640,9 +67954,8 @@ w1: WHILE vQuantity >= vPacking DO NOW() FROM packingSite ps JOIN host h ON h.id = ps.hostFk - JOIN item i ON i.name = 'Shipping cost' - WHERE ps.id = vPackingSiteFk - LIMIT 1; + JOIN productionConfig pc + WHERE ps.id = vPackingSiteFk; SET vExpeditionFk = LAST_INSERT_ID(); @@ -67671,6 +67984,7 @@ w1: WHILE vQuantity >= vPacking DO DELETE FROM sale WHERE quantity = 0 AND id = vSaleFk; + END WHILE; END ;; @@ -68535,10 +68849,6 @@ BEGIN ORDER BY (vQuantity % `grouping`) ASC LIMIT 1; - IF vNewPrice IS NULL THEN - CALL util.throw('price retrieval failed'); - END IF; - IF vNewPrice > vOldPrice THEN SET vFinalPrice = vOldPrice; SET vOption = 'substitution'; @@ -72898,7 +73208,6 @@ BEGIN JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk @@ -72907,12 +73216,10 @@ BEGIN LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk - WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE()) - AND al.code IN ('PACKED', 'DELIVERED') + WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' AND w.code = 'ALG' - AND dm.code = 'DELIVERY' AND t.id = vSelf GROUP BY t.id; @@ -79329,7 +79636,7 @@ BEGIN SELECT c.id clientFk, c.name, c.phone, - c.mobile, + bt.description, c.salesPersonFk, u.name username, aai.invoiced, @@ -79345,10 +79652,11 @@ BEGIN LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id JOIN vn.clientType ct ON ct.code = c.typeFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk WHERE a.isActive AND c.isActive AND ct.code = 'normal' - AND c.businessTypeFk <> 'worker' + AND bt.code <> 'worker' GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; @@ -81524,18 +81832,16 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `Proveedores_cargueras` +-- Temporary table structure for view `Proveedores_cargueras` -- DROP TABLE IF EXISTS `Proveedores_cargueras`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_cargueras` ( - `Id_Proveedor` int(10) unsigned NOT NULL, - PRIMARY KEY (`Id_Proveedor`), - CONSTRAINT `Proveedores_cargueras_supplierFk` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de espcializacion para señalar las compañias que prestan servicio de transitario'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Proveedores_cargueras`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Proveedores_cargueras` AS SELECT + 1 AS `Id_Proveedor` */; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Proveedores_comunicados__` @@ -81921,19 +82227,17 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `Tramos` +-- Temporary table structure for view `Tramos` -- DROP TABLE IF EXISTS `Tramos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tramos` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Tramo` time NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `Tramo` (`Tramo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Tramos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Tramos` AS SELECT + 1 AS `id`, + 1 AS `Tramo` */; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `V_edi_item_track` @@ -83003,20 +83307,20 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `dock` +-- Table structure for table `dock__` -- -DROP TABLE IF EXISTS `dock`; +DROP TABLE IF EXISTS `dock__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `dock` ( +CREATE TABLE `dock__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(5) NOT NULL, `xPos` int(11) DEFAULT NULL, `yPos` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-03-05'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -83349,7 +83653,8 @@ DROP TABLE IF EXISTS `gastos_resumen`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `gastos_resumen` AS SELECT - 1 AS `Id_Gasto`, + 1 AS `id`, + 1 AS `Id_Gasto`, 1 AS `year`, 1 AS `month`, 1 AS `importe`, @@ -83675,7 +83980,7 @@ CREATE TABLE `payroll_basess__` ( KEY `payroll_basess_1_idx` (`id_tipobasess`), KEY `payroll_basess_2_idx` (`empresa_id`), CONSTRAINT `payroll_basess_1` FOREIGN KEY (`id_tipobasess`) REFERENCES `payroll_tipobasess__` (`id_payroll_tipobasess`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `payroll_centros` (`empresa_id`) ON UPDATE CASCADE + CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`payrollWorkCenter` (`empresa_id__`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -83710,42 +84015,33 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `payroll_centros` +-- Temporary table structure for view `payroll_centros` -- DROP TABLE IF EXISTS `payroll_centros`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_centros` ( - `cod_centro` int(11) NOT NULL, - `Centro` varchar(255) NOT NULL, - `nss_cotizacion` varchar(15) NOT NULL, - `domicilio` varchar(255) NOT NULL, - `poblacion` varchar(45) NOT NULL, - `cp` varchar(5) NOT NULL, - `empresa_id` int(10) NOT NULL, - `codempresa` int(11) DEFAULT NULL, - PRIMARY KEY (`cod_centro`,`empresa_id`), - KEY `payroll_centros_ix1` (`empresa_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `payroll_centros`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `payroll_centros` AS SELECT + 1 AS `cod_centro`, + 1 AS `codempresa` */; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `payroll_conceptos` +-- Temporary table structure for view `payroll_conceptos` -- DROP TABLE IF EXISTS `payroll_conceptos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_conceptos` ( - `conceptoid` int(11) NOT NULL, - `concepto` varchar(255) DEFAULT NULL, - `isSalaryAgreed` tinyint(1) NOT NULL DEFAULT 0, - `isVariable` tinyint(1) NOT NULL, - `isException` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Excepciones a tener en cuenta al importar conceptos en el proceso de importación de ficheros A3.', - PRIMARY KEY (`conceptoid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `payroll_conceptos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `payroll_conceptos` AS SELECT + 1 AS `conceptoid`, + 1 AS `concepto`, + 1 AS `isSalaryAgreed`, + 1 AS `isVariable`, + 1 AS `isException` */; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `payroll_datos__` @@ -83767,7 +84063,7 @@ CREATE TABLE `payroll_datos__` ( `TributaIRPF` tinyint(4) NOT NULL, PRIMARY KEY (`codtrabajador`,`codempresa`,`conceptoid`,`Fecha`), KEY `fgkey_payrolldatos_1_idx` (`conceptoid`), - CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE + CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `vn`.`payrollComponent` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -83791,29 +84087,17 @@ CREATE TABLE `payroll_embargos__` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `payroll_employee` +-- Temporary table structure for view `payroll_employee` -- DROP TABLE IF EXISTS `payroll_employee`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_employee` ( - `CodTrabajador` int(11) NOT NULL, - `nss` varchar(23) NOT NULL, - `codpuesto` int(10) NOT NULL, - `codempresa` int(10) NOT NULL, - `codcontrato` int(10) NOT NULL, - `FAntiguedad` date NOT NULL, - `grupotarifa` int(10) NOT NULL, - `codcategoria` int(10) NOT NULL, - `ContratoTemporal` tinyint(1) NOT NULL DEFAULT 0, - `workerFk` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`CodTrabajador`,`codempresa`), - KEY `sajvgfh_idx` (`codpuesto`), - KEY `payroll_employee_workerFk_idx` (`workerFk`), - CONSTRAINT `payroll_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `payroll_employee`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `payroll_employee` AS SELECT + 1 AS `CodTrabajador`, + 1 AS `codempresa` */; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `payroll_tipobasess__` @@ -85096,137 +85380,6 @@ DELIMITER ; -- /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `account_conciliacion_add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `account_conciliacion_add`() -BEGIN - UPDATE account_conciliacion ac - JOIN - ( - SELECT idaccount_conciliacion, @c:= if(@id = id_calculated, @c + 1, 1) contador, - @id:= id_calculated as id_calculated, concat(id_calculated,'(',@c,')') as new_id - FROM account_conciliacion - JOIN - ( - select id_calculated, count(*) rep, @c:= 0, @id:= concat('-',id_calculated) - from account_conciliacion - group by id_calculated - having rep > 1 - ) sub using(id_calculated) - ) sub2 using(idaccount_conciliacion) - SET ac.id_calculated = sub2.new_id; - - INSERT INTO Cajas(Cajafecha, Partida, Serie, Concepto, Entrada, - Salida, Id_Banco,empresa_id, warehouse_id, - Proveedores_account_id, id_calculated, InForeignValue, OutForeignValue, Id_Trabajador) - SELECT Fechaoperacion, TRUE, 'MB', ac.Concepto, IF(DebeHaber = 2 AND currencyFk = 1, importe,null), - IF(DebeHaber = 1 AND currencyFk = 1, importe, null), a.id, sa.supplierFk, 1, - ac.Id_Proveedores_account, ac.id_calculated, IF(DebeHaber = 2 AND NOT currencyFk = 1, importe, null), - IF(DebeHaber = 1 AND NOT currencyFk = 1, importe, null), account.myUser_getId() - FROM account_conciliacion ac - JOIN vn.supplierAccount sa on sa.id = ac.Id_Proveedores_account - JOIN vn.accounting a ON a.id = sa.accountingFk - LEFT JOIN Cajas c on c.id_calculated = ac.id_calculated - WHERE c.Id_Caja IS NULL; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `agencia_volume` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencia_volume`() -BEGIN - DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE()); - DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated; - CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated - ( - ticketFk INT PRIMARY KEY - ,boxes INT DEFAULT 0 - ); - - INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes) - SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox) - FROM vn.ticket t - JOIN vn.saleVolume sv ON sv.ticketFk = t.id - JOIN vn.volumeConfig vc - WHERE t.shipped BETWEEN vStarted AND vEnded - AND IFNULL(t.packages,0) = 0 - GROUP BY t.id; - SELECT * FROM - ( - SELECT ag.id agency_id, - CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia, - count(*) expediciones, - sum(t.packages) Bultos, - sum(tpe.boxes) Faltan - FROM vn.ticket t - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.country c ON w.countryFk = c.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id - WHERE t.shipped BETWEEN vStarted AND vEnded - AND ag.isOwn = FALSE - GROUP BY ag.id - ) sub - ORDER BY Agencia; - - DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `article` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `article`() -BEGIN -/** - * Crea la tabla temporal: article_inventory - */ - DROP TEMPORARY TABLE IF EXISTS article_inventory; - CREATE TEMPORARY TABLE article_inventory - ( - `article_id` INT(11) NOT NULL PRIMARY KEY, - `future` DATETIME - ) - ENGINE = MEMORY; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `article_multiple_buy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -88527,7 +88680,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `payrollCenter` AS select `b`.`cod_centro` AS `codCenter`,`b`.`Centro` AS `name`,`b`.`nss_cotizacion` AS `nss`,`b`.`domicilio` AS `street`,`b`.`poblacion` AS `city`,`b`.`cp` AS `postcode`,`b`.`empresa_id` AS `companyFk`,`b`.`codempresa` AS `companyCode` from `vn2008`.`payroll_centros` `b` */; +/*!50001 VIEW `payrollCenter` AS select `b`.`workCenterFkA3` AS `codCenter`,`b`.`companyFkA3` AS `companyCode` from `payrollWorkCenter` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89793,7 +89946,25 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isSerious` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; +/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Proveedores_cargueras` +-- + +/*!50001 DROP VIEW IF EXISTS `Proveedores_cargueras`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `Proveedores_cargueras` AS select `fs`.`supplierFk` AS `Id_Proveedor` from `vn`.`supplierFreight` `fs` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90032,6 +90203,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Tramos` +-- + +/*!50001 DROP VIEW IF EXISTS `Tramos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `Tramos` AS select `s`.`id` AS `id`,`s`.`section` AS `Tramo` from `vn`.`timeSlots` `s` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `V_edi_item_track` -- @@ -90945,7 +91134,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `gastos_resumen` AS select `es`.`expenseFk` AS `Id_Gasto`,`es`.`year` AS `year`,`es`.`month` AS `month`,`es`.`amount` AS `importe`,`es`.`companyFk` AS `empresa_id` from `vn`.`expenseManual` `es` */; +/*!50001 VIEW `gastos_resumen` AS select `es`.`id` AS `id`,`es`.`expenseFk` AS `Id_Gasto`,`es`.`year` AS `year`,`es`.`month` AS `month`,`es`.`amount` AS `importe`,`es`.`companyFk` AS `empresa_id` from `vn`.`expenseManual` `es` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91148,6 +91337,60 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `payroll_centros` +-- + +/*!50001 DROP VIEW IF EXISTS `payroll_centros`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `payroll_centros` AS select `pwc`.`workCenterFkA3` AS `cod_centro`,`pwc`.`companyFkA3` AS `codempresa` from `vn`.`payrollWorkCenter` `pwc` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `payroll_conceptos` +-- + +/*!50001 DROP VIEW IF EXISTS `payroll_conceptos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `payroll_conceptos` AS select `pc`.`id` AS `conceptoid`,`pc`.`name` AS `concepto`,`pc`.`isSalaryAgreed` AS `isSalaryAgreed`,`pc`.`isVariable` AS `isVariable`,`pc`.`isException` AS `isException` from `vn`.`payrollComponent` `pc` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `payroll_employee` +-- + +/*!50001 DROP VIEW IF EXISTS `payroll_employee`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `payroll_employee` AS select `pw`.`workerFkA3` AS `CodTrabajador`,`pw`.`companyFkA3` AS `codempresa` from `vn`.`payrollWorker` `pw` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `plantpassport` -- @@ -91661,4 +91904,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-04-08 7:13:58 +-- Dump completed on 2024-04-18 7:15:58 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index cdf611d5b..f8923508a 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -10997,4 +10997,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-04-08 7:14:22 +-- Dump completed on 2024-04-18 7:16:17 From e909d647579befa0b0361311f4f5e8c0d4e6b8ad Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 18 Apr 2024 10:01:22 +0200 Subject: [PATCH 102/152] 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 d6ec84e1fe120221ab5a491d701c10491c55124d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Apr 2024 12:07:00 +0200 Subject: [PATCH 103/152] hotfix --- db/routines/vn/procedures/collection_new.sql | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 1292707af..d4e896473 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -45,15 +45,6 @@ proc:BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - - RESIGNAL; - END; - SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, @@ -79,12 +70,6 @@ proc:BEGIN JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; - SET vLockName = CONCAT_WS('/', - 'collection_new', - vWarehouseFk, - vItemPackingTypeFk - ); - IF NOT GET_LOCK(vLockName, vLockTime) THEN LEAVE proc; END IF; From 9295bddaa84bc15c66319d50f3d35b1fee212e61 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Apr 2024 13:06:45 +0200 Subject: [PATCH 104/152] 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 d5dc057c361c2ff91831c954b65fa30ace7453db Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Apr 2024 13:52:30 +0200 Subject: [PATCH 105/152] hotfix: changes --- .../vn/procedures/collection_assign.sql | 24 +++++++++++++++---- db/routines/vn/procedures/collection_new.sql | 15 ++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 49b4eb7bb..bfc7b0f93 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -13,11 +13,16 @@ proc:BEGIN * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vWarehouseFk INT; + DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 15; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - DO RELEASE_LOCK('collection_assign'); + IF vLockName IS NOT NULL THEN + DO RELEASE_LOCK(vLockName); + END IF; RESIGNAL; END; @@ -28,7 +33,7 @@ proc:BEGIN SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections FROM tCollection - JOIN productionConfig pc ; + JOIN productionConfig pc; DROP TEMPORARY TABLE tCollection; @@ -37,7 +42,18 @@ proc:BEGIN LEAVE proc; END IF; - IF NOT GET_LOCK('collection_assign',vLockTime) THEN + SELECT warehouseFk, itemPackingTypeFk + INTO vWarehouseFk, vItemPackingTypeFk + FROM operator + WHERE workerFk = vUserFk; + + SET vLockName = CONCAT_WS('/', + 'collection_assign', + vWarehouseFk, + vItemPackingTypeFk + ); + + IF NOT GET_LOCK(vLockName, vLockTime) THEN LEAVE proc; END IF; @@ -90,6 +106,6 @@ proc:BEGIN SET workerFk = vUserFk WHERE id = vCollectionFk; - DO RELEASE_LOCK('collection_assign'); + DO RELEASE_LOCK(vLockName); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index d4e896473..1292707af 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -45,6 +45,15 @@ proc:BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF vLockName IS NOT NULL THEN + DO RELEASE_LOCK(vLockName); + END IF; + + RESIGNAL; + END; + SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, @@ -70,6 +79,12 @@ proc:BEGIN JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; + SET vLockName = CONCAT_WS('/', + 'collection_new', + vWarehouseFk, + vItemPackingTypeFk + ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN LEAVE proc; END IF; From bb8379f8dbdec5bbec388193b03aea16bd01eeed Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Apr 2024 14:42:29 +0200 Subject: [PATCH 106/152] refactor: refs #6724 Minor change --- .../vn/procedures/invoiceInTax_getFromEntries.sql | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index 5a53b7543..631b8f31c 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -4,16 +4,9 @@ BEGIN DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - DECLARE vIsBooked BOOLEAN DEFAULT FALSE; - SELECT isBooked INTO vIsBooked - FROM invoiceIn ii - WHERE id = vInvoiceInFk; + CALL invoiceIn_checkBooked(vInvoiceInFk); - IF vIsBooked THEN - CALL util.throw('A booked invoice cannot be modified'); - END IF; - SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk From 87e23b49e700f96378da9bd17741c4b473cf3448 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 15:19:19 +0200 Subject: [PATCH 107/152] hotFix: change require to import --- front/salix/components/change-password/index.js | 2 +- front/salix/components/reset-password/index.js | 2 +- modules/ticket/front/main/index.js | 2 +- modules/worker/front/descriptor/index.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/front/salix/components/change-password/index.js b/front/salix/components/change-password/index.js index 7e30bf54e..93241b781 100644 --- a/front/salix/components/change-password/index.js +++ b/front/salix/components/change-password/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -const UserError = require('vn-loopback/util/user-error'); +import UserError from 'core/lib/user-error'; export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state, $location) { diff --git a/front/salix/components/reset-password/index.js b/front/salix/components/reset-password/index.js index c0a10cc52..b49eab841 100644 --- a/front/salix/components/reset-password/index.js +++ b/front/salix/components/reset-password/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -const UserError = require('vn-loopback/util/user-error'); +import UserError from 'core/lib/user-error'; export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state, $location) { diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js index c49418cfc..64bb7e191 100644 --- a/modules/ticket/front/main/index.js +++ b/modules/ticket/front/main/index.js @@ -1,6 +1,6 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -const UserError = require('vn-loopback/util/user-error'); +import UserError from 'core/lib/user-error'; export default class Ticket extends ModuleMain { fetchParams($params) { diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index d7962369c..75265acb4 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -1,6 +1,6 @@ import ngModule from '../module'; import Descriptor from 'salix/components/descriptor'; -const UserError = require('vn-loopback/util/user-error'); +import UserError from 'core/lib/user-error'; class Controller extends Descriptor { constructor($element, $, $rootScope) { super($element, $); From 9ec51e534d2401ec827fce1d132f2c258c9ed78c Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Apr 2024 15:39:25 +0200 Subject: [PATCH 108/152] fix: jenkins puppeteer --- back/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/back/Dockerfile b/back/Dockerfile index 363192a0b..7728b1d90 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -40,6 +40,7 @@ RUN apt-get update \ WORKDIR /salix COPY print/package.json print/pnpm-lock.yaml print/ +RUN pnpx puppeteer browsers install chrome RUN pnpm install --prod --prefix=print COPY package.json pnpm-lock.yaml ./ From f766b9a3b128c281b9512c38a43150683e63ff7b Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Apr 2024 07:17:53 +0200 Subject: [PATCH 109/152] fix: try to fix puppeteer --- back/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/Dockerfile b/back/Dockerfile index 7728b1d90..f537a7062 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -40,12 +40,12 @@ RUN apt-get update \ WORKDIR /salix COPY print/package.json print/pnpm-lock.yaml print/ -RUN pnpx puppeteer browsers install chrome RUN pnpm install --prod --prefix=print COPY package.json pnpm-lock.yaml ./ COPY loopback/package.json loopback/ RUN pnpm install --prod +RUN node node_modules/puppeteer/install.mjs COPY loopback loopback COPY back back From 8b468b52ea64e109bb217879a8fb01fdca8b907c Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Apr 2024 07:21:35 +0200 Subject: [PATCH 110/152] fix: try to fix puppeteer --- Jenkinsfile | 2 ++ back/Dockerfile | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d700ce1f9..8e625de59 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,8 @@ pipeline { stage('Back') { steps { sh 'pnpm install --prefer-offline' + sh 'pnpx puppeteer browsers install chrome' + // sh 'node node_modules/puppeteer/install.mjs' } } stage('Print') { diff --git a/back/Dockerfile b/back/Dockerfile index f537a7062..363192a0b 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -45,7 +45,6 @@ RUN pnpm install --prod --prefix=print COPY package.json pnpm-lock.yaml ./ COPY loopback/package.json loopback/ RUN pnpm install --prod -RUN node node_modules/puppeteer/install.mjs COPY loopback loopback COPY back back From 91e13070c729abf5c29185d2f57bb2886983bdbb Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Apr 2024 07:27:54 +0200 Subject: [PATCH 111/152] fix: try to fix puppeteer --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8e625de59..bfe31fc60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,8 +71,7 @@ pipeline { stage('Back') { steps { sh 'pnpm install --prefer-offline' - sh 'pnpx puppeteer browsers install chrome' - // sh 'node node_modules/puppeteer/install.mjs' + sh 'node node_modules/puppeteer/install.mjs' } } stage('Print') { From 067e71e3ce0ff545cc1a38e8b97148e9438dcf31 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 07:48:45 +0200 Subject: [PATCH 112/152] 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 113/152] 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 114/152] 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 115/152] 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 116/152] 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 28c08d8b18a1b1aad8c7613e931d6f8938a469c2 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 10:58:19 +0200 Subject: [PATCH 117/152] feat: refs #7237 company_getSuppliersDebt --- db/routines/vn/procedures/company_getSuppliersDebt.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql index 50c64669c..6335ccbe3 100644 --- a/db/routines/vn/procedures/company_getSuppliersDebt.sql +++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql @@ -188,7 +188,7 @@ BEGIN FROM tPendingDuedates vp LEFT JOIN supplier s ON s.id = vp.supplierFk LEFT JOIN client c ON c.fi = s.nif - JOIN clientRisk cr ON cr.clientFk = c.id + LEFT JOIN clientRisk cr ON cr.clientFk = c.id AND cr.companyFk = vp.companyFk LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk From e601310d3e347281535d2031ce0b9e9ecdd372e2 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:27:54 +0200 Subject: [PATCH 118/152] 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 119/152] 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 120/152] 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 121/152] 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 122/152] 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 e0cd08b28033a9d1c4aa0d4164594298f9154ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Apr 2024 14:10:11 +0200 Subject: [PATCH 123/152] fix: hotfix importar A3 Ticket 175840 --- db/routines/vn2008/views/payrollWorker.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/db/routines/vn2008/views/payrollWorker.sql b/db/routines/vn2008/views/payrollWorker.sql index d4ada9aa0..6199e98b8 100644 --- a/db/routines/vn2008/views/payrollWorker.sql +++ b/db/routines/vn2008/views/payrollWorker.sql @@ -1,6 +1,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER - VIEW `vn2008`.`payroll_employee` -AS SELECT `pw`.`workerFkA3` AS `CodTrabajador`, - `pw`.`companyFkA3` AS `codempresa` -FROM `vn`.`payrollWorker` `pw` + VIEW `vn2008`.`payroll_employee` AS +SELECT + `pw`.`workerFkA3` AS `CodTrabajador`, + `pw`.`companyFkA3` AS `codempresa`, + `pw`.`workerFk` AS `workerFk` +FROM + `vn`.`payrollWorker` `pw`; \ No newline at end of file From ad317cb5e545f5c53bded7269823ec14c7047bc2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 19 Apr 2024 14:11:35 +0200 Subject: [PATCH 124/152] 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 65892625d5462e48feb0d182104317ad61fcf052 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Apr 2024 14:17:49 +0200 Subject: [PATCH 125/152] feat: #7231 Collection_assing more time and throw --- db/routines/vn/procedures/collection_assign.sql | 7 +++---- db/routines/vn/procedures/collection_new.sql | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index bfc7b0f93..f6000e87d 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_assign`( vUserFk INT, OUT vCollectionFk INT ) -proc:BEGIN +BEGIN /** * Comprueba si existen colecciones libres que se ajustan * al perfil del usuario y le asigna la más antigua. @@ -16,7 +16,7 @@ proc:BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 15; + DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -39,7 +39,6 @@ proc:BEGIN IF vHasTooMuchCollections THEN CALL util.throw('Hay colecciones pendientes'); - LEAVE proc; END IF; SELECT warehouseFk, itemPackingTypeFk @@ -54,7 +53,7 @@ proc:BEGIN ); IF NOT GET_LOCK(vLockName, vLockTime) THEN - LEAVE proc; + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); END IF; -- Se eliminan las colecciones sin asignar que estan obsoletas diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 1292707af..f3767ddf3 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT) -proc:BEGIN +BEGIN /** * Genera colecciones de tickets sin asignar trabajador. * @@ -26,7 +26,7 @@ proc:BEGIN DECLARE vHasUniqueCollectionTime BOOL; DECLARE vDone INT DEFAULT FALSE; DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 15; + DECLARE vLockTime INT DEFAULT 30; DECLARE vFreeWagonFk INT; DECLARE c1 CURSOR FOR @@ -86,7 +86,7 @@ proc:BEGIN ); IF NOT GET_LOCK(vLockName, vLockTime) THEN - LEAVE proc; + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); END IF; -- Se prepara el tren, con tantos vagones como sea necesario. From a0126748e2e3da3a2085d887e9cffea36a098ede Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 19 Apr 2024 14:19:34 +0200 Subject: [PATCH 126/152] 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 127/152] 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 128/152] 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 129/152] 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 130/152] 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 131/152] 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 132/152] 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 133/152] 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 134/152] 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 135/152] 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 136/152] 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 137/152] =?UTF-8?q?feat:=20Varias=20l=C3=ADneas=20farming?= =?UTF-8?q?=20en=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 138/152] 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 139/152] 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 140/152] 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 141/152] 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 142/152] 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 143/152] 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 144/152] 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 145/152] 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 146/152] 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 147/152] 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 148/152] 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 149/152] 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 150/152] 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 151/152] 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 152/152] 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,