feat: refs #4948 Added ticket_doSelfConsumptionPackaging proc & event
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
0af3713a07
commit
7496a419cc
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`ticket_doSelfConsumptionPackaging`
|
||||||
|
ON SCHEDULE EVERY 1 DAY
|
||||||
|
STARTS '2024-04-19 04:05:00.000'
|
||||||
|
ON COMPLETION PRESERVE
|
||||||
|
ENABLE
|
||||||
|
DO CALL ticket_doSelfConsumptionPackaging(util.yesterday(), util.yesterday())$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,39 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doSelfConsumptionPackaging`(
|
||||||
|
vDateFrom DATE,
|
||||||
|
vDateTo DATE
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Crea un ticket de autoconsumo de un rango determinado de fechas.
|
||||||
|
*
|
||||||
|
* @param vDateFrom Fecha desde
|
||||||
|
* @param vDateTo Fecha hasta
|
||||||
|
*/
|
||||||
|
DECLARE vClientFk INT;
|
||||||
|
DECLARE vAddressFk INT;
|
||||||
|
DECLARE vTicketFk INT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
|
SELECT clientSelfConsumptionFk, addressSelfConsumptionFk
|
||||||
|
INTO vClientFk, vAddressFk
|
||||||
|
FROM productionConfig;
|
||||||
|
|
||||||
|
SELECT id INTO vWarehouseFk
|
||||||
|
FROM warehouse
|
||||||
|
WHERE code = 'alg';
|
||||||
|
|
||||||
|
INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk)
|
||||||
|
SELECT vClientFk, vWarehouseFk, vDateFrom, 'AUTOCONSUMO CAJAS', vAddressFk;
|
||||||
|
|
||||||
|
SET vTicketFk = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
INSERT INTO sale(itemFk, ticketFk, concept, quantity)
|
||||||
|
SELECT i.id, vTicketFk, i.name, COUNT(*)
|
||||||
|
FROM expedition e
|
||||||
|
JOIN packaging p ON p.id = e.packagingFk
|
||||||
|
JOIN item i ON i.id = p.itemFk
|
||||||
|
WHERE e.created BETWEEN vDateFrom AND util.dayEnd(vDateTo)
|
||||||
|
GROUP BY e.packagingFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
Loading…
Reference in New Issue