2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-05-16 16:48:59 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
|
|
|
|
vBookNumber INT,
|
2024-01-15 11:31:03 +00:00
|
|
|
vDated DATE,
|
|
|
|
vSubaccount VARCHAR(12),
|
|
|
|
vAccount VARCHAR(12),
|
|
|
|
vConcept VARCHAR(25),
|
|
|
|
vDebit DOUBLE,
|
|
|
|
vCredit DOUBLE,
|
|
|
|
vEuro DOUBLE,
|
|
|
|
vSerie CHAR(1),
|
|
|
|
vInvoice VARCHAR(8),
|
|
|
|
vVat DOUBLE,
|
|
|
|
vRe DOUBLE,
|
|
|
|
vAux TINYINT,
|
2024-05-16 16:48:59 +00:00
|
|
|
vCompanyFk INT
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
|
|
|
RETURNS int(11)
|
|
|
|
NOT DETERMINISTIC
|
|
|
|
NO SQL
|
|
|
|
BEGIN
|
2024-05-16 16:48:59 +00:00
|
|
|
IF vBookNumber IS NULL THEN
|
|
|
|
CALL ledger_next(YEAR(vDated), vBookNumber);
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
|
|
|
|
INSERT INTO XDiario
|
2024-05-16 16:48:59 +00:00
|
|
|
SET ASIEN = vBookNumber,
|
|
|
|
FECHA = vDated,
|
|
|
|
SUBCTA = vSubaccount,
|
|
|
|
CONTRA = vAccount,
|
|
|
|
CONCEPTO = vConcept,
|
|
|
|
EURODEBE = vDebit,
|
|
|
|
EUROHABER = vCredit,
|
|
|
|
BASEEURO = vEuro,
|
|
|
|
SERIE = vSerie,
|
|
|
|
FACTURA = vInvoice,
|
|
|
|
IVA = vVat,
|
|
|
|
RECEQUIV = vRe,
|
|
|
|
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
|
|
|
MONEDAUSO = 2,
|
|
|
|
empresa_id = vCompanyFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-05-16 16:48:59 +00:00
|
|
|
RETURN vBookNumber;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
2024-05-16 16:48:59 +00:00
|
|
|
DELIMITER ;
|