2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `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
|
|
|
|
)
|
|
|
|
RETURNS int(11)
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
DECLARE vAccount VARCHAR(12);
|
|
|
|
DECLARE vSubaccount VARCHAR(12);
|
|
|
|
DECLARE vAsiento INT DEFAULT NULL;
|
|
|
|
|
|
|
|
-- Inserta el registro en cajas
|
|
|
|
|
|
|
|
INSERT INTO till
|
|
|
|
SET
|
|
|
|
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;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
SELECT accountingAccount INTO vSubaccount
|
|
|
|
FROM `client` WHERE id = vClient;
|
|
|
|
|
|
|
|
SET vAsiento = xdiario_new
|
|
|
|
(
|
|
|
|
vAsiento
|
|
|
|
,vDated
|
|
|
|
,vAccount
|
|
|
|
,vSubaccount
|
|
|
|
,vConcept
|
|
|
|
,vAmount
|
|
|
|
,0
|
|
|
|
,0
|
|
|
|
,NULL -- Serie
|
|
|
|
,NULL -- Factura
|
|
|
|
,NULL -- IVA
|
|
|
|
,NULL -- Recargo
|
|
|
|
,FALSE -- Auxiliar
|
|
|
|
,vCompany
|
|
|
|
);
|
|
|
|
DO xdiario_new
|
|
|
|
(
|
|
|
|
vAsiento
|
|
|
|
,vDated
|
|
|
|
,vSubaccount
|
|
|
|
,vAccount
|
|
|
|
,vConcept
|
|
|
|
,0
|
|
|
|
,vAmount
|
|
|
|
,0
|
|
|
|
,NULL -- Serie
|
|
|
|
,NULL -- Factura
|
|
|
|
,NULL -- IVA
|
|
|
|
,NULL -- Recargo
|
|
|
|
,FALSE -- Auxiliar
|
|
|
|
,vCompany
|
|
|
|
);
|
|
|
|
|
|
|
|
RETURN NULL;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|