Lorenzo
04/14/2025, 12:01 PMCeligo AI
04/14/2025, 12:01 PMAI generated answer (using internal Slack threads):To get the amount charged to a client over a period programmatically, you can use SuiteQL or SuiteScript to sum up all invoices and credit memos for that client within the specified period. Here is a sample SuiteQL query that you can use to get the total amount from invoices:
sql
SELECT SUM(amount)
FROM transaction
WHERE entity = :customerId
AND tranDate BETWEEN :startDate AND :endDate
AND type = 'CustInvc'
And another one for credit memos:
sql
SELECT SUM(amount)
FROM transaction
WHERE entity = :customerId
AND tranDate BETWEEN :startDate AND :endDate
AND type = 'CustCred'
In these queries, :customerId
is the internal ID of the customer, :startDate
and :endDate
are the start and end dates of the period you are interested in.
You can execute these queries using the N/query
module in SuiteScript:
javascript
var suiteQL = "SELECT SUM(amount) FROM transaction WHERE entity = " + customerId + " AND tranDate BETWEEN '" + startDate + "' AND '" + endDate + "' AND type = 'CustInvc'";
var result = query.runSuiteQL({query: suiteQL});
Remember to replace customerId
, startDate
, and endDate
with actual values. Also, make sure to subtract the total amount of credit memos from the total amount of invoices to get the net amount charged to the client.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/14/2025, 12:01 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.787353754
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.780861437
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.780796826
Celigo AI
04/14/2025, 12:02 PM