//greg
07/03/2024, 2:58 AM['type','anyof','CustPymt'], 'AND',
['appliedtotransaction','noneof','@NONE@'], 'AND',
['datecreated','within','thisweek'],
michoel
07/03/2024, 7:37 AMSELECT
t.id,
t.tranid,
t.trandate,
t.createddate,
pt.tranid AS applied_to
FROM
transaction t
JOIN PreviousTransactionLink ptl ON ptl.nextdoc = t.id
JOIN transaction pt ON ptl.previousdoc = pt.id
WHERE
t.type = 'CustPymt'
AND ptl.linktype = 'Payment'
AND pt.type = 'CustInvc'
AND t.createddate BETWEEN BUILTIN.RELATIVE_RANGES('TW', 'START', 'DATETIME_AS_DATE') AND BUILTIN.RELATIVE_RANGES('TW', 'END', 'DATETIME_AS_DATE')
//greg
07/03/2024, 1:48 PM