feat: refs#6493 Cambios solicitados procedimientos
This commit is contained in:
parent
92cd61460e
commit
d3df3e3376
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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`;
|
Loading…
Reference in New Issue