68 lines
1.6 KiB
SQL
68 lines
1.6 KiB
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`pay`(IN datFEC DATE
|
|
, IN idPROV INT
|
|
, IN dblIMPORTE DOUBLE
|
|
, IN idMONEDA INT
|
|
, IN dblDIVISA DOUBLE
|
|
, IN idCAJA INT
|
|
, IN idPAYMET INT
|
|
, IN dblGASTOS DOUBLE
|
|
, IN strCONCEPTO VARCHAR(40)
|
|
, IN idEMP INT)
|
|
BEGIN
|
|
|
|
-- Registro en la tabla Cajas
|
|
INSERT INTO Cajas ( Concepto
|
|
, Serie
|
|
, Numero
|
|
, Salida
|
|
, Cajafecha
|
|
, Partida
|
|
, Id_Banco
|
|
, Id_Trabajador
|
|
,empresa_id
|
|
,conciliado)
|
|
|
|
SELECT CONCAT('n/pago a ', Proveedor)
|
|
, 'R'
|
|
, idPROV
|
|
, dblIMPORTE
|
|
, datFEC
|
|
, 1
|
|
, idCAJA
|
|
, account.myUser_getId()
|
|
, idEMP
|
|
, 1
|
|
FROM Proveedores
|
|
WHERE Id_Proveedor = idPROV;
|
|
|
|
-- Registro en la tabla pago
|
|
INSERT INTO pago(fecha
|
|
, dueDated
|
|
, id_proveedor
|
|
, importe
|
|
, id_moneda
|
|
, divisa
|
|
, id_banco
|
|
, pay_met_id
|
|
, g_bancarios
|
|
, concepte
|
|
, empresa_id)
|
|
|
|
VALUES(datFEC
|
|
, datFEC
|
|
, idPROV
|
|
, dblIMPORTE
|
|
, idMONEDA
|
|
, IF(dblDIVISA = 0, NULL, dblDIVISA)
|
|
, idCAJA
|
|
, idPAYMET
|
|
, dblGASTOS
|
|
, strCONCEPTO
|
|
, idEMP);
|
|
|
|
SELECT LAST_INSERT_ID() as pago_id;
|
|
|
|
END$$
|
|
DELIMITER ;
|