Returns summarized Accounts Receivable information based on a specific customer.
-- Contributor: Tim Dietrich (timdietrich@me.com) -- Additional Info: https://timdietrich.me/blog/netsuite-suiteql-accounts-receivable-aging/ SELECT BUILTIN.DF( Transaction.Entity ) AS Customer, SUM( CASE WHEN ( TRUNC( SYSDATE ) - Transaction.DueDate ) < 1 THEN COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ELSE 0 END ) AS Current, SUM( CASE WHEN ( TRUNC( SYSDATE ) - Transaction.DueDate ) BETWEEN 1 AND 30 THEN COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ELSE 0 END ) AS Balance30, SUM( CASE WHEN ( TRUNC( SYSDATE ) - Transaction.DueDate ) BETWEEN 31 AND 60 THEN COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ELSE 0 END ) AS Balance60, SUM( CASE WHEN ( TRUNC( SYSDATE ) - Transaction.DueDate ) BETWEEN 61 AND 90 THEN COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ELSE 0 END ) AS Balance90, SUM( CASE WHEN ( TRUNC( SYSDATE ) - Transaction.DueDate ) > 90 THEN COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ELSE 0 END ) AS Balance90Plus, SUM ( COALESCE( TransactionAccountingLine.AmountUnpaid, 0 ) - COALESCE( TransactionAccountingLine.PaymentAmountUnused, 0 ) ) AS Total FROM Transaction INNER JOIN TransactionAccountingLine ON ( TransactionAccountingLine.Transaction = Transaction.ID ) INNER JOIN Customer ON ( Customer.ID = Transaction.Entity ) WHERE ( Transaction.Posting = 'T' ) AND ( Transaction.Voided = 'F' ) AND ( ( TransactionAccountingLine.AmountUnpaid <> 0 ) OR ( TransactionAccountingLine.PaymentAmountUnused <> 0 ) ) GROUP BY BUILTIN.DF( Transaction.Entity ) ORDER BY BUILTIN.DF( Transaction.Entity )
Click here to return to the list of available queries.
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.