salix/db/routines/vn/functions/till_new.sql

74 lines
1.2 KiB
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-05-21 15:31:29 +00:00
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`(
vClient INT,
vBank INT,
vAmount DOUBLE,
vConcept VARCHAR(25),
vDated DATE,
vSerie CHAR(1),
vBatch TINYINT,
vNumber INT,
vCompany SMALLINT,
vWorker INT
)
BEGIN
DECLARE vAccount VARCHAR(12);
DECLARE vSubaccount VARCHAR(12);
DECLARE vAsiento INT DEFAULT NULL;
-- Inserta el registro en cajas
INSERT INTO till
SET
2024-05-21 15:31:29 +00:00
workerFk = vWorker,
bankFk = vBank,
`in` = vAmount,
concept = vConcept,
dated = vDated,
serie = vSerie,
isAccountable = vBatch,
`number` = vNumber,
companyFk = vCompany;
-- Inserta los asientos contables
SELECT account INTO vAccount
2024-03-14 07:36:19 +00:00
FROM accounting WHERE id = vBank;
SELECT accountingAccount INTO vSubaccount
FROM `client` WHERE id = vClient;
2024-05-21 15:31:29 +00:00
CALL xdiario_new(
vAsiento,
vDated,
vAccount,
vSubaccount,
vConcept,
vAmount,
0,
0,
NULL, -- Serie
NULL, -- Factura
NULL, -- IVA
NULL, -- Recargo
FALSE, -- Auxiliar
vCompany,
vAsiento);
2024-05-21 15:31:29 +00:00
CALL xdiario_new(
vAsiento,
vDated,
vSubaccount,
vAccount,
vConcept,
0,
vAmount,
0,
NULL, -- Serie
NULL, -- Factura
NULL, -- IVA
NULL, -- Recargo
FALSE, -- Auxiliar
vCompany,
vAsiento);
END$$
DELIMITER ;