SELECT p.field_name1 as empresa,imp.name as impuesto,cat.categoria,vto.anticipo,
DATE_FORMAT(CONCAT(`vto`.`anio`,'-',`vto`.`mes`,'-',`vto`.`dia`),'%Y-%m-%d')AS `vencimiento`,pi.importe
FROM vto_person_impuesto pi
join persons p on pi.person_id = p.id
left join vto_impuestos imp on pi.impuesto_id = imp.id
left join vto_categoria_imp cat on pi.categoria_imp_id = cat.id
left join vto_vencimiento vto on pi.vto_id = vto.id
left join person_configurations pc on pi.person_id = pc.person_id
where pc.active =2
and anio = 2019
and vto.mes =1

union

select p1.field_name1 as empresa, 'Honorarios Contables' as impuesto, null as categoria, 'Mes Vencido' as anticipo,
'del 1 al 10' as vencimiento ,pc.honorario as importe
from person_configurations pc
join persons p1 on pc.person_id = p1.id
where pc.active =2

order by empresa,vencimiento;
