80 lines
1.2 KiB
MySQL
80 lines
1.2 KiB
MySQL
|
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
|
||
|
FROM bank WHERE id = vBank;
|
||
|
|
||
|
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 ;
|