Sales order report

distru-report-sales-ordersRead

Sales order report, one row per order, line item or tax rate.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
batchIdsstring[]NoOrder contains these batches, so LINE_ITEM rows include its other lines. Resolve via distru-search-batches.
brandIdsstring[]NoOrder contains a product of these brands (on LINE_ITEM, the line's product). Resolve via distru-search-companies, or read it on a distru-search-products row.
customerGroupIdsstring[]NoResolve via distru-search-lookups (type COMPANY_GROUP).
customerIdsstring[]NoResolve via distru-search-companies.
deliveryDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Setting it lifts the orderDatetime default.
deliveryDatetime.endstringNo
deliveryDatetime.startstringNo
dueDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Payment due date. Setting it lifts the orderDatetime default.
dueDatetime.endstringNo
dueDatetime.startstringNo
matchedWithComplianceTransferbooleanNoOrder matched to a Metrc transfer.
menuIdsstring[]NoResolve via distru-search-menus.
orderDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Defaults to the last 30 days when no other date filter is set. 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
orderSourcesenum[]
LEAFLINKEXTERNAL_BUYERINTERNAL_USERAPI
NoLEAFLINK: has a LeafLink ID; EXTERNAL_BUYER: placed by a buyer user; INTERNAL_USER: has a creator or menu; API: any other.
paymentStatusesenum[]
NOT_PAIDPAYINGPAIDOVERPAID
No
productGroupIdsstring[]NoLINE_ITEM only. Resolve via distru-search-lookups (type PRODUCT_GROUP).
productIdsstring[]NoOrder contains these products, so LINE_ITEM rows include its other lines. Resolve via distru-search-products.
sampleenum
ONLYEXCLUDE
NoLINE_ITEM only. Sample line items.
searchstringNoCase-insensitive substring of order number, LeafLink short ID or customer name (name skipped under 2 characters).
shippedFromLicenseIdsstring[]NoResolve via distru-search-licenses.
statusesenum[]
CANCELEDCOMPLETEDDELIVEREDDELIVERINGPENDINGPROCESSINGREADY_TO_SHIP
NoDefault: every status except CANCELED. Merged orders are never included; their items count on the order they merged into. Canceled orders keep their tax charges: on TAX_RATE list CANCELED only when asked.
taxIdsstring[]NoTAX_RATE only. Narrows both the orders counted (those with one of these taxes) and the taxes summed. Resolve via distru-search-lookups (type TAX).
totalobjectNoOrder grand total net of returns, in dollars.
total.maxnumberNoInclusive.
total.minnumberNoInclusive.
tradeSamplePackagesenum
ONLYEXCLUDE
NoLINE_ITEM only. Line items whose package is a trade sample. A line item with no package is dropped either way.
productCategoryIdsstring[]NoLINE_ITEM only.
productSubcategoryIdsstring[]NoLINE_ITEM only.
productTagIdsstring[]NoLINE_ITEM only.
vendorIdsstring[]NoLINE_ITEM only.
maxRowsLimitintegerNoRows per page. Defaults to 500.
rowsPerenum
ORDERLINE_ITEMTAX_RATE
YesORDER: one row per order. LINE_ITEM: one per line item. TAX_RATE: one per tax name and rate, summed over the matching orders.

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[].orderDatestringAlways
rows[].orderDateUtcstringAlways
rows[].deliveryDatestringCan be null
rows[].deliveryDateUtcstringCan be null
rows[].dueDatestringCan be null
rows[].dueDateUtcstringCan be null
rows[].orderNumberstringAlways
rows[].salesOrderIdstringAlways
rows[].customerstringCan be null
rows[].customerIdstringCan be null
rows[].statusenum
CANCELEDCOMPLETEDDELIVEREDDELIVERINGPENDINGPROCESSINGREADY_TO_SHIP
Can be null
rows[].paidstringAlways
rows[].outstandingstringAlways
rows[].subtotalstringAlways
rows[].taxesstringAlways
rows[].discountsTaxesNotIncludedstringAlways
rows[].chargesTaxesNotIncludedstringAlways
rows[].returnsstringAlways
rows[].totalstringAlways
rows[].ownerstringCan be null
rows[].salesOrderOwnerIdstringCan be null
rows[].orderSourceenum
APIEXTERNAL_BUYERINTERNAL_USERLEAFLINK
Can 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[].lineItemIdstringAlways
rows[].orderIdstringAlways
rows[].orderDatestringAlways
rows[].orderDateUtcstringAlways
rows[].deliveryDatestringCan be null
rows[].deliveryDateUtcstringCan be null
rows[].dueDatestringCan be null
rows[].dueDateUtcstringCan be null
rows[].orderNumberstringAlways
rows[].statusenum
CANCELEDCOMPLETEDDELIVEREDDELIVERINGPENDINGPROCESSINGREADY_TO_SHIP
Can be null
rows[].productstringAlways
rows[].productIdstringAlways
rows[].productSkustringAlways
rows[].defaultUnitCoststringCan be null
rows[].defaultUnitPricestringAlways
rows[].defaultWholesalePricestringCan be null
rows[].brandstringCan be null
rows[].brandIdstringCan be null
rows[].vendorstringAlways
rows[].vendorIdstringAlways
rows[].orderItemPricestringAlways
rows[].priceBasestringAlways
rows[].priceTierModeenum
AUTONONEOVERRIDE
Always
rows[].priceTierobjectCan be null
rows[].priceTier.idstringAlways
rows[].priceTier.namestringAlways
rows[].priceTier.pricingobjectAlways
rows[].priceTier.pricing.typeenum
AMOUNT_OFFFLAT_PRICEPERCENT_OFF
Always
rows[].priceTier.pricing.valuestringCan be null
rows[].priceTier.isLivebooleanAlways
rows[].returnedQuantitystringAlways
rows[].quantitystringAlways
rows[].categorystringAlways
rows[].subcategorystringCan be null
rows[].groupstringCan be null
rows[].customerstringCan be null
rows[].customerIdstringCan be null
rows[].salesRepstringCan be null
rows[].salesOrderOwnerIdstringCan be null
rows[].invoiceNumbersstringCan be null
rows[].upcstringCan be null
rows[].batchNumberstringCan be null
rows[].batchIdstringCan be null
rows[].packageIdstringCan be null
rows[].sourcePackagestringCan 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[].taxTypestringCan be null
rows[].taxRatestringCan be null
rows[].totalTaxstringAlways
rows[].customFieldsobject[]Always
rows[].customFields[].keystringAlways
rows[].customFields[].labelstringAlways
rows[].customFields[].valuestringCan be null
What the AI reads

Sales order report at the grain rowsPer picks. ORDER: dates, customer, status, owner, money totals and payment state, no line items; for listing or totaling orders. LINE_ITEM: each line's product with brand, vendor and batch, its order's dates, status, customer and sales rep, its price tier, and for Metrc companies package and potency in customFields; for what sold on which orders, batch- or package-level sales, samples, and price tiers applied and their discounts, deleted tiers included. TAX_RATE: totalTax per tax name and rate over the matching orders, one name on several rows when charged at several rates; for tax totals and liability (per order: ORDER's taxes). For totals per customer, product or sales rep use distru-report-sales-totals; for invoices distru-report-invoice-history; for cost and margin per line distru-report-cogs; for one order's detail distru-get-sales-order; for a product-by-order quantity grid distru-report-order-fulfillment. LINE_ITEM rows come newest first by order date. Dates come in company timezone and UTC (*Utc), as YYYY-MM-DD HH:MM:SS.ffffff, no offset. ORDER total is net of returns; outstanding is total minus payments. LINE_ITEM quantity is net of returnedQuantity; batchNumber is the package's or Distru batch's number, never the batch name; customer is null on an order with no customer yet; priceTier is the tier as it priced the line, isLive false once edited or deleted; a line's tier discount is (priceBase - orderItemPrice) x quantity; defaultUnitPrice is today's list price. TAX_RATE counts only tax charges; taxRate is a percent ("27.00" is 27%), null for a flat tax; taxType is null for an unnamed charge. Money, quantities and rates 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.