Suiteql get all SalesOrder that were invoiced last...
# ask-stanley-ai
r
Suiteql get all SalesOrder that were invoiced last month
c
AI generated answer (using internal Slack threads):
To get all SalesOrders that were invoiced last month using SuiteQL, you can create a query that joins the SalesOrder and Invoice tables on the 'createdfrom' field. The 'createdfrom' field in the Invoice table corresponds to the SalesOrder from which the Invoice was created. You would also need to filter the Invoices based on their 'trandate' field to get only those Invoices that were created last month. Here is a sample SuiteQL query:
Copy code
sql
SELECT 
    so.internalid AS salesorder_id, 
    inv.internalid AS invoice_id
FROM 
    transaction so
JOIN 
    transaction inv ON so.internalid = inv.createdfrom
WHERE 
    inv.type = 'Invoice' 
    AND MONTH(inv.trandate) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
    AND YEAR(inv.trandate) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
    AND so.type = 'SalesOrder'
This query will return the internal IDs of the SalesOrders and their corresponding Invoices that were created last month. Please note that this is a simplified example and you might need to adjust it according to your specific needs, such as including additional fields in the SELECT clause or adding more conditions in the WHERE clause. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811357379
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80397439
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.802856743
Please provide your feedback on this answer.