My recommendations would be to try this out in layers as you have a few sub-queries in the code, and then work your way up the line. You may even want to encapsulate the various sub-queries as views and then join them in the parent query.
In this chunk, we have the parent query referring to subquery(1) which in turn is calling subquery(2).
It appears that the aggregate functions are in Subquery(2), however; the GROUP BY clause is outside of that loop on Subquery(1)
from(
select poslovni_partner, iznos_sa_porezom as Nabavka
from (
select poslovni_partner, SUM(ISNULL(iznos_sa_porezom,0)) as iznos_sa_porezom
from mp_ulazni_racun_roba_lista
union all
select poslovni_partner, SUM(ISNULL(iznos_sa_porezom,0)) as iznos_sa_porezom
from mp_ulazni_racun_ostalo_lista
) a
group by poslovni_partner, iznos_sa_porezom
) x1