select TAX as TAXID,  sum(SUBTOTAL * ITSPERCENTAGE / 100) as TOTALTAX
from SALESRETURNLINE 
join INVITEM on INVITEM.ITSID = SALESRETURNLINE.INVITEM
join INVITEMTAXCATEGORY on INVITEMTAXCATEGORY.ITSID = INVITEM.TAXCATEGORY
join INVITEMTAXCATEGORYLINE on INVITEMTAXCATEGORYLINE.ITSOWNER = INVITEMTAXCATEGORY.ITSID
where SALESRETURNLINE.REVERSEDID is null and SALESRETURNLINE.ITSOWNER = :ITSOWNER
group by TAX;
