Search code examples
c#netsuite

NetSuite: obtaining invoice balance


I searched high and low but could not find any decent reference how to get paid and outstanding amounts for the invoice in NetSuite using SuiteTalk API.

Documentation is non-existent and so are the samples so I'm poking in the dark here.

When invoice is retrieved using get method, I kind of expected these to be specified (fields amountPaid and amountRemaining) but they are not.

The next port of call, unfortunately, is to search for customer payments that have been applied to the target invoice. Search works but, to make the matter worse, each payment is returned without any apply details so extra call is required to get all apply details and figure out the total payment amount applied to the invoice.

Is that REALLY the only way to do it?

(And I probably would have to consider deposits and deposit applications as they are separate record types. Sigh)

Any help is appreciated

UPDATE: Working code sample

long internalInvoiceId = 42;
TransactionSearchAdvanced tsa = new TransactionSearchAdvanced()
{
    columns = new TransactionSearchRow()
    {
        basic = new TransactionSearchRowBasic()
        {
            total = new SearchColumnDoubleField[] { new SearchColumnDoubleField() },
            amount = new SearchColumnDoubleField[] { new SearchColumnDoubleField() },
            amountPaid = new SearchColumnDoubleField[] { new SearchColumnDoubleField() },
            amountRemaining = new SearchColumnDoubleField[] { new SearchColumnDoubleField() }
        }
    },
    criteria = new TransactionSearch()
    {
        basic = new TransactionSearchBasic()
        {
            mainLine = new SearchBooleanField()
            {
                searchValue = true,
                searchValueSpecified = true
            },
            type = new SearchEnumMultiSelectField()
            {
                @operator = SearchEnumMultiSelectFieldOperator.anyOf,
                operatorSpecified = true,
                searchValue = new string[] { "_invoice" }
            },
            internalIdNumber = new SearchLongField()
            {
                @operator = SearchLongFieldOperator.equalTo,
                operatorSpecified = true,
                searchValue = internalInvoiceId,
                searchValueSpecified = true
            }
        }
    }
};

SearchResult sr = nss.search(tsa);

Solution

  • Do a transaction search.

    Criteria:

    Main Line: Yes
    Type: Invoice
    (Optional) Internal ID: "The internal id of your Invoice"

    Result/Columns:

    Amount Paid
    Amount Remaining

    Translate the above to SuiteTalk API (TransactionSearchAdvanced) and you should be able to get what you want.