2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`cobro`(IN datFEC DATE
|
|
|
|
, IN idCLI INT
|
|
|
|
, IN dblIMPORTE DOUBLE
|
|
|
|
, IN idCAJA INT
|
|
|
|
, IN idPAYMET INT
|
|
|
|
, IN strCONCEPTO VARCHAR(40)
|
|
|
|
, IN idEMP INT
|
|
|
|
, IN idWH INT
|
|
|
|
, IN idTRABAJADOR INT)
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE bolCASH BOOLEAN;
|
|
|
|
DECLARE cuenta_banco BIGINT;
|
|
|
|
DECLARE cuenta_cliente BIGINT;
|
|
|
|
DECLARE max_asien INT;
|
|
|
|
-- XDIARIO
|
|
|
|
-- No se asientan los cobros directamente, salvo en el caso de las cajas de CASH
|
|
|
|
SELECT (at2.code = 'cash') INTO bolCASH FROM Bancos b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.Id_Banco = idCAJA;
|
|
|
|
IF bolCASH THEN
|
|
|
|
SELECT Cuenta INTO cuenta_banco
|
|
|
|
FROM Bancos
|
|
|
|
WHERE Id_Banco = idCAJA;
|
|
|
|
SELECT Cuenta INTO cuenta_cliente
|
|
|
|
FROM Clientes
|
|
|
|
WHERE Id_Cliente = idCLI;
|
|
|
|
CALL vn.ledger_next(max_asien);
|
2024-02-01 08:49:44 +00:00
|
|
|
INSERT INTO vn.XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
|
2024-01-15 11:31:03 +00:00
|
|
|
SELECT max_asien,datFEC,SUBCTA,CONTRA,strCONCEPTO,EURODEBE,EUROHABER,idEMP
|
|
|
|
FROM(SELECT cuenta_banco SUBCTA, cuenta_cliente CONTRA, 0 EURODEBE, dblIMPORTE EUROHABER
|
|
|
|
UNION ALL
|
|
|
|
SELECT cuenta_cliente SUBCTA, cuenta_banco CONTRA, dblIMPORTE EURODEBE, 0 EUROHABER
|
|
|
|
) gf;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
-- CAJERA
|
|
|
|
INSERT INTO Cajas(Id_Trabajador,
|
|
|
|
Id_Banco,
|
|
|
|
Entrada,
|
|
|
|
Concepto,
|
|
|
|
Cajafecha,
|
|
|
|
Serie,
|
|
|
|
Partida,
|
|
|
|
Numero,
|
|
|
|
empresa_id,
|
|
|
|
warehouse_id
|
|
|
|
)
|
|
|
|
VALUES (idTRABAJADOR,
|
|
|
|
idCAJA,
|
|
|
|
dblIMPORTE,
|
|
|
|
strCONCEPTO,
|
|
|
|
datFEC,
|
|
|
|
'A',
|
|
|
|
TRUE,
|
|
|
|
idCLI,
|
|
|
|
idEMP,
|
|
|
|
idWH
|
|
|
|
);
|
|
|
|
|
|
|
|
-- RECIBO
|
|
|
|
INSERT INTO Recibos(Entregado,
|
|
|
|
Fechacobro,
|
|
|
|
Id_Trabajador,
|
|
|
|
Id_Banco,
|
|
|
|
Id_Cliente,
|
|
|
|
Id_Factura,
|
|
|
|
empresa_id
|
|
|
|
)
|
|
|
|
VALUES ( dblIMPORTE,
|
|
|
|
datFEC,
|
|
|
|
idTRABAJADOR,
|
|
|
|
idCAJA,
|
|
|
|
idCLI,
|
|
|
|
strCONCEPTO,
|
|
|
|
idEMP
|
|
|
|
);
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|