Sales totals report

distru-report-sales-totalsRead

Sales totals over a date range, per customer, product or sales rep.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
customerGroupIdsstring[]NoCUSTOMER only. Resolve via distru-search-lookups (type COMPANY_GROUP).
customerIdsstring[]NoPRODUCT only. Resolve via distru-search-companies.
excludeCustomerIdsstring[]NoPRODUCT only. Applied after customerIds.
locationIdsstring[]NoPRODUCT only. Line items shipped from these locations. Resolve via distru-search-locations.
orderDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Defaults to the last 30 days. If no rows match, check when the last order was with distru-search-sales-orders (sortBy ORDER_DATE DESC, limit 1) before concluding nothing sold: the account may have stopped using Distru orders, or ship only through compliance transfers (distru-report-inventory-transaction-history, transactionTypes COMPLIANCE_PACKAGE_ADDED_TO_TRANSFER).
orderDatetime.endstringNo
orderDatetime.startstringNo
ownerIdsstring[]NoCounts only orders these sales reps own, not the customer's or product's owner. On SALES_REP, the reps ranked: default every active user, and a listed one is ranked even when deactivated. Resolve via distru-search-users.
searchstringNoPRODUCT or SALES_REP only. PRODUCT: substring of product name or SKU. SALES_REP: counts only orders whose number, LeafLink short ID or customer name contains it, case-insensitive (name skipped under 2 characters); reps with no match still appear with 0s.
shippedFromLicenseIdsstring[]NoPRODUCT only. Resolve via distru-search-licenses.
statusesenum[]
PENDINGPROCESSINGREADY_TO_SHIPDELIVERINGDELIVEREDCOMPLETEDCANCELED
NoDefault: every status except CANCELED and MERGED.
productCategoryIdsstring[]NoPRODUCT only.
productSubcategoryIdsstring[]NoPRODUCT only.
productTagIdsstring[]NoPRODUCT only.
vendorIdsstring[]NoPRODUCT only.
brandIdsstring[]NoPRODUCT only.
productGroupIdsstring[]NoPRODUCT only.
maxRowsLimitintegerNoRows per page. Defaults to 500.
rowsPerenum
CUSTOMERPRODUCTSALES_REP
Yes

Output

This tool returns one of 3 shapes, depending on its inputs.

Presence on a nested field assumes its parent exists.

Result shape 1

FieldTypePresenceDescription
nextCursorstringCan be absentPass as cursor to fetch the next page. Present only when meta.truncated.
metaobjectAlways
meta.reportstringAlways
meta.dateRangestringAlways
meta.rowLimitnumberAlways
meta.offsetnumberAlways
meta.rowCountnumberAlways
meta.totalRowCountnumberAlways
meta.truncatedbooleanAlways
meta.columnsobject[]Always
meta.columns[].keystringAlways
meta.columns[].labelstringAlways
rowsobject[]Always
rows[].namestringAlways
rows[].customerIdstringAlways
rows[].lastOrderDatestringCan be null
rows[].orderCountstringAlways
rows[].totalReceivedstringAlways
rows[].totalSalesstringAlways
rows[].ownerstringCan be null
rows[].customerOwnerIdstringCan be null
rows[].categorystringCan be null
rows[].relationshipTypestringCan be null
rows[].customFieldsobject[]Always
rows[].customFields[].keystringAlways
rows[].customFields[].labelstringAlways
rows[].customFields[].valuestringCan be null

Result shape 2

FieldTypePresenceDescription
nextCursorstringCan be absentPass as cursor to fetch the next page. Present only when meta.truncated.
metaobjectAlways
meta.reportstringAlways
meta.dateRangestringAlways
meta.rowLimitnumberAlways
meta.offsetnumberAlways
meta.rowCountnumberAlways
meta.totalRowCountnumberAlways
meta.truncatedbooleanAlways
meta.columnsobject[]Always
meta.columns[].keystringAlways
meta.columns[].labelstringAlways
rowsobject[]Always
rows[].namestringAlways
rows[].productIdstringAlways
rows[].skustringAlways
rows[].quantitySoldstringAlways
rows[].totalSalesstringAlways
rows[].unitTypestringAlways
rows[].categorystringAlways
rows[].subcategorystringCan be null
rows[].groupstringCan be null
rows[].vendorstringAlways
rows[].vendorIdstringAlways
rows[].productOwnerstringCan be null
rows[].unitCoststringCan be null
rows[].salePricestringAlways
rows[].wholesalePricestringCan be null
rows[].shippedFromLicensestringCan be null
rows[].upcstringCan be null
rows[].customFieldsobject[]Always
rows[].customFields[].keystringAlways
rows[].customFields[].labelstringAlways
rows[].customFields[].valuestringCan be null

Result shape 3

FieldTypePresenceDescription
nextCursorstringCan be absentPass as cursor to fetch the next page. Present only when meta.truncated.
metaobjectAlways
meta.reportstringAlways
meta.dateRangestringAlways
meta.rowLimitnumberAlways
meta.offsetnumberAlways
meta.rowCountnumberAlways
meta.totalRowCountnumberAlways
meta.truncatedbooleanAlways
meta.columnsobject[]Always
meta.columns[].keystringAlways
meta.columns[].labelstringAlways
rowsobject[]Always
rows[].leaderboardRankstringAlways
rows[].userstringCan be null
rows[].userIdstringAlways
rows[].orderCountstringAlways
rows[].salesPreTaxstringAlways
rows[].totalSalesstringAlways
rows[].customFieldsobject[]Always
rows[].customFields[].keystringAlways
rows[].customFields[].labelstringAlways
rows[].customFields[].valuestringCan be null
What the AI reads

Sales totals over a date range, one row per what rowsPer picks. CUSTOMER: each customer with a matching order, with order count, total received (payments applied) and total sales (order totals net of returns); for top customers or customer spend. PRODUCT: each product sold, with quantity sold, total sales net of returns and the product's attributes; for best sellers and revenue by product. SALES_REP: a leaderboard of every user, including those with no matching orders (0 totals), ranked by total sales, with order count, salesPreTax and totalSales (including tax), both net of returns; an order counts for its owner; for rep performance. Totals are negative when returns exceed sales. CUSTOMER rows come by totalSales, highest first; lastOrderDate is the customer's latest order that wasn't canceled or merged, as M/D/YYYY in the company's timezone, and can fall outside the range; null when all were. For the orders or line items behind a total use distru-report-sales-orders; for quantity per product per order distru-report-order-fulfillment; for cost and margin distru-report-cogs; for a rep's orders distru-search-sales-orders with ownerIds. Money, quantities and counts are numeric strings. Returns 500 rows by default (maxRowsLimit, up to 5000). When meta.truncated is true more rows exist: repeat the call with the same filters, any date range made explicit so every page covers the same one, and cursor set to nextCursor — or narrow the filters when you need a summary rather than every row.