text: select 5 as SRTY, PAYMTO.DAT, 'SATAXRECV' as ACDB, TAX.NME as SADNM, TAX.IID as SADID, 1008 as SADTY, PUINTXLN.TOT as DEBT,
  'PAYABLE' as ACCR, DBCR.NME as SACNM, DBCR.IID as SACID, 1002 as SACTY, PUINTXLN.TOT as CRED
  from PAYMTO
  join PURINV on PURINV.IID=PAYMTO.INV
  join PUINTXLN on PURINV.IID=PUINTXLN.OWNR
  join TAX on TAX.IID=PUINTXLN.TAX
  join DBCR on DBCR.IID=PURINV.DBCR
  where PUINTXLN.RVID is null and PURINV.MDENR=1 and round(TOPA+PAYMTO.TOT,2)>=round(PURINV.TOT,2) :WHEAD
  