CREATE DEFINER=`root`@`localhost` PROCEDURE `SPCrearImpuestoHonorarios`()
BEGIN
	declare done int default 0;
	declare empresa_id int;
	declare vtoID int default 1179;
    declare importe decimal(20,2) default 0.00;
    
    
    DECLARE tableHonorario CURSOR FOR 
	select person_id, honorario from person_configurations where active = 2;

   

	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

	OPEN tableHonorario;
	REPEAT

	FETCH tableHonorario INTO empresa_id, importe;

		
  		      
		while vtoID <= 1190 DO
			
			insert into vto_person_impuesto 
				(person_id, impuesto_id, categoria_imp_id, vto_id,importe)
					VALUES
                (empresa_id, 39, null, vtoID, importe );
        
        	Set vtoID = vtoID + 1;
        end while;  

        Set vtoID = 1179;

	UNTIL done END REPEAT;

  	CLOSE tableHonorario;
  	
  
  END