i want to get All Customer Payments within a date ...
# suiteql
u
i want to get All Customer Payments within a date window where they have been applied to an invoice. - in saved search I can do this with the appliedtotransaction fields but i do not see this in SuiteQL Tool below is part of the filters that work in a N/search (transaction being the type) - how would I go about doing something similar in SuiteQL?
Copy code
['type','anyof','CustPymt'], 'AND', 
 ['appliedtotransaction','noneof','@NONE@'], 'AND', 
 ['datecreated','within','thisweek'],
m
Copy code
SELECT 
  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')
🙌 1
u
Thanks @michoel