Skip to content

Apply Client Payment

Applies an existing client payment (NetSuite Customer Payment) to one or more invoices. This works the same way as the Apply subtab on a payment in the NetSuite UI: one payment can be applied to several invoices in a single request.

The same request can also change or remove existing applications: each target's amount is the amount the application is set to, and an amount of 0 un-applies it.

Base URL

https://{{accountid}}.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=customscript_prac_api_applyclpayment&deploy=customdeploy_prac_api_applyclpayment_v1

HTTP: PUT

Sets how an existing client payment is applied to one or more transactions.

Required URL Parameters

Name Value Notes
script customscript_prac_api_applyclpayment
deploy customdeploy_prac_api_applyclpayment_v1

Payload

The payload must be JSON. The applying transaction is the payment; the apply to transactions are the invoices. Each one can be identified by its transaction ID (tranId / applyingTranId) or its internal ID (id / applyingId).

Format:

{
    "applyingTranId OR applyingId": "transaction ID OR internal ID",
    "applyTo": [
        {
            "tranId OR id": "transaction ID OR internal ID",
            "amount": number
        }
    ]
}
Property Type Notes
applyingTranId {{string}} Transaction ID of the payment, e.g. PYMT6338. Use this or applyingId.
applyingId {{integer}} Internal ID of the payment. Use this or applyingTranId.
applyTo {{array}} One or more transactions to apply the payment to. Required; cannot be empty.
applyTo[].tranId {{string}} Transaction ID of an invoice, e.g. INV17641. Use this or id.
applyTo[].id {{integer}} Internal ID of the transaction. Use this or tranId.
applyTo[].amount {{number}} Required. The amount to apply to this transaction. 0 removes (un-applies) an existing application.

Rules

  • Amounts are set, not added. If the payment already has $50 applied to an invoice and you send "amount": 75, the application becomes $75 (not $125). Send 0 to un-apply.
  • Only the listed transactions change. Any other applications already on the payment are left as they are.
  • All or nothing. Every item in applyTo is checked before anything is saved. If any item is invalid, the request fails and nothing is applied.
  • IDs and transaction IDs can be mixed. For example, applyingTranId with an applyTo item that uses id. If both are supplied for the same transaction, the internal ID is used.
  • A transaction can only appear once in applyTo.
  • The transaction must be available on the payment's Apply list, i.e. an open transaction for the same client.
  • amount cannot exceed what can be applied to that transaction (its amount due plus anything this payment already applies to it), and the total increase across the request cannot exceed the payment's unapplied amount.

Journal Entries

A payment can also be applied to a journal entry on the client's account, but journal entries must be identified by internal ID (id). tranId can only be used for invoices; a journal entry's transaction ID cannot be used in the apply JSON and will return PRAC_API_TRANID_NOT_FOUND.

Examples

Apply a payment to one invoice, using transaction IDs:

{
    "applyingTranId": "PYMT6338",
    "applyTo": [
        {
            "tranId": "INV17641",
            "amount": 1.11
        }
    ]
}

Apply a payment to several invoices, using internal IDs:

{
    "applyingId": 16150,
    "applyTo": [
        { "id": 8594, "amount": 100.00 },
        { "id": 8601, "amount": 250.00 }
    ]
}

Un-apply one invoice and apply to a journal entry (by internal ID) in the same request:

{
    "applyingTranId": "PYMT6338",
    "applyTo": [
        { "tranId": "INV17641", "amount": 0 },
        { "id": 16769, "amount": 50.00 }
    ]
}