select 12 as SOURCETYPE, SALESRETURN.ITSID as SOURCEID, SALESRETURN.ITSDATE,
'SalesTaxFromSalReturns' as ACCDEBIT, 2003 as SUBACCDEBITTYPE, TAX.ITSID as SUBACCDEBITID, TAX.ITSNAME as SUBACCDEBIT, sum(SALESRETURNTAXLINE.ITSTOTAL) as DEBIT,
null as ACCCREDIT, null as SUBACCCREDITTYPE, null as SUBACCCREDITID, null as SUBACCCREDIT, 0 as CREDIT
from SALESRETURNTAXLINE
join SALESRETURN on SALESRETURN.ITSID = SALESRETURNTAXLINE.ITSOWNER
join TAX on TAX.ITSID = SALESRETURNTAXLINE.TAX
where SALESRETURNTAXLINE.REVERSEDID is null and SALESRETURN.REVERSEDID is null and HASMADEACCENTRIES = 0 and TAX.ITSTYPE in (1,2) and TAX.DUEMETHOD = 0 :WHEREADD
group by SOURCETYPE, SOURCEID, ITSDATE, ACCDEBIT, SUBACCDEBITTYPE, SUBACCDEBITID, SUBACCDEBIT, ACCCREDIT, SUBACCCREDITTYPE, SUBACCCREDITID, SUBACCCREDIT
