Search customer credits

distru-search-creditsRead

Searches customer credits from overpayments, returns, QuickBooks or issued by hand.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
limitintegerNoDefault: 10
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
creditNumberstringNoCase-insensitive substring of the per-company sequential credit number: "104" matches "1042" and "1104".
customerIdsstring[]NoResolve via distru-search-companies.
externalNotestringNoCase-insensitive substring of the customer-visible note.
internalNotestringNoCase-insensitive substring of the staff-only note.
ownerIdsstring[]NoCredit owner, not creator. Resolve via distru-search-users.
searchstringNoCase-insensitive substring of credit number, either note or owner full name. Not customer name; use customerIds.
sourcesenum[]
INVOICE_PAYMENTQB_CREDIT_MEMOQB_PAYMENTRETURNUSER
NoINVOICE_PAYMENT: overpayment of a payment recorded in Distru; QB_PAYMENT: unapplied amount of a payment synced from QuickBooks; QB_CREDIT_MEMO: created in QuickBooks, though a credit from another source can carry a qbCreditMemoId too, and a RETURN credit whose return was removed can become one.
statusesenum[]
ACTIVECANCELEDREDEEMED
NoACTIVE: not canceled, remaining balance above 0; REDEEMED: not canceled, fully applied.
sortByobjectNoDefault UPDATED_AT DESC.
sortBy.directionenum
ASCDESC
Yes
sortBy.fieldenum
AMOUNTCREDIT_NUMBERINSERTED_ATREMAINING_BALANCESOURCESTATUSUPDATED_AT
YesAMOUNT: current face value; REMAINING_BALANCE: amount minus applied uses; STATUS only separates canceled from non-canceled.

Output

Presence on a nested field assumes its parent exists.

FieldTypePresence
hasMorebooleanAlways
nextCursorstringCan be absent
totalCountintegerCan be absent
itemsobject[]Always
items[].idstringAlways
items[].creditNumberstringAlways
items[].statusenum
ACTIVECANCELEDREDEEMED
Always
items[].sourceenum
INVOICE_PAYMENTQB_CREDIT_MEMOQB_PAYMENTRETURNUSER
Always
items[].amountstringAlways
items[].originalAmountstringAlways
items[].remainingBalancestringAlways
items[].customerobjectCan be null
items[].customer.idstringAlways
items[].customer.namestringNull or absent
items[].ownerobjectCan be null
items[].owner.idstringAlways
items[].owner.profileobjectAlways
items[].owner.profile.fullNamestringAlways
items[].externalNotestringCan be null
items[].internalNotestringCan be null
items[].qbCreditMemoIdstringCan be null
items[].qbPaymentIdstringCan be null
items[].qbSyncStatusenum
DELETED_IN_QBOERRORNOT_SYNCEDPARTIALLY_SYNCEDPENDINGSYNCED
Can be null
items[].insertedAtstringAlways
items[].updatedAtstringAlways
items[].canceledAtstringCan be null
What the AI reads

One row per customer credit (from an overpayment, a return, QuickBooks, or issued by a user), without where it was applied, its line items or its history: for those use distru-get-credit. At least one filter required. No ID filter: find a credit by creditNumber or search. amount is the current face value, originalAmount the value at issue. remainingBalance is amount minus the credit already applied; a CANCELED credit keeps its balance but can't be spent, so leave CANCELED credits out of what a customer has available. INVOICE_PAYMENT and QB_PAYMENT credits are a payment's overpayment. customer is null when the caller's team can't see it. qbSyncStatus ERROR: distru-search-quickbooks-activities with creditIds gives the error. ERROR or NOT_SYNCED: distru-sync-to-quickbooks pushes it, or says why it can't.