7226-testToMaster_2416 #2320
|
@ -1,33 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`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 ;
|
|
|
@ -1,44 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`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 ;
|
|
|
@ -1,15 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`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 ;
|
|
Loading…
Reference in New Issue