select 9 as SOURCETYPE, PREPAYMENTFROM.ITSID as SOURCEID, PREPAYMENTFROM.ITSDATE, PREPAYMENTFROM.ACCCASH as ACCDEBIT,
SUBACCCASHTYPE as SUBACCDEBITTYPE, SUBACCCASHID as SUBACCDEBITID, SUBACCCASH as SUBACCDEBIT, PREPAYMENTFROM.ITSTOTAL as DEBIT,
'PrepaymentsFrom' as ACCCREDIT, 2004 as SUBACCCREDITTYPE, DEBTORCREDITOR.ITSID as SUBACCCREDITID, DEBTORCREDITOR.ITSNAME as SUBACCCREDIT, PREPAYMENTFROM.ITSTOTAL as CREDIT
from PREPAYMENTFROM
join DEBTORCREDITOR on DEBTORCREDITOR.ITSID = PREPAYMENTFROM.CUSTOMER
where PREPAYMENTFROM.REVERSEDID is null and HASMADEACCENTRIES = 0 :WHEREADD
