DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`(
	vSelf INT
)
BEGIN
/**
 * Comprueba si una factura recibida está contabilizada,
 * y si lo está retorna un throw.
 *
 * @param vSelf Id invoiceIn
 */
	DECLARE vIsBooked BOOL;

	SELECT isBooked INTO vIsBooked
		FROM invoiceIn
		WHERE id = vSelf;

	IF vIsBooked THEN
		CALL util.throw('InvoiceIn is already booked');
	END IF;
END$$
DELIMITER ;
