Cost of goods sold report

distru-report-cogsRead

Cost of goods sold: one row per sold line item on a COMPLETED order that was not fully returned, with price, actual and default cost, profit and margin.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
deliveryDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Delivery date of the line item's order. Setting it lifts the orderDatetime default.
deliveryDatetime.endstringNo
deliveryDatetime.startstringNo
orderDatetimeobjectNoInclusive. YYYY-MM-DD (whole days, company timezone) or ISO 8601 with a UTC offset. Defaults to the last 30 days unless deliveryDatetime is set; there is no all-time default, so send a range to widen it. 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
productCategoryIdsstring[]NoProduct category of the rows. ORed with productSubcategoryIds; a listed subcategory of a listed category narrows that category to it. Resolve via distru-search-lookups (type PRODUCT_CATEGORY).
productSubcategoryIdsstring[]NoProduct subcategory of the rows. See productCategoryIds. Resolve via distru-search-lookups (type PRODUCT_CATEGORY, each row's subcategories).
productTagIdsstring[]NoAny of these tags on the product. Resolve via distru-search-lookups (type PRODUCT_TAG).
vendorIdsstring[]NoThe vendor set on the product, not the company an order was placed with. Resolve via distru-search-companies.
brandIdsstring[]NoProduct brand of the rows, itself a company. Resolve via distru-search-companies, or read it on a distru-search-products row.
productGroupIdsstring[]NoResolve via distru-search-lookups (type PRODUCT_GROUP).
maxRowsLimitintegerNoRows per page. Defaults to 500.

Output

Presence on a nested field assumes its parent exists.

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[].orderNumberstringAlways
rows[].salesOrderIdstringAlways
rows[].finalInputstringAlways
rows[].costOriginstringCan be null
rows[].productNamestringAlways
rows[].productIdstringAlways
rows[].skustringAlways
rows[].productBrandstringCan be null
rows[].brandIdstringCan be null
rows[].productCategorystringAlways
rows[].packagestringCan be null
rows[].packageIdstringCan be null
rows[].batchstringCan be null
rows[].batchIdstringCan be null
rows[].quantitystringAlways
rows[].unitTypestringAlways
rows[].unitPricestringAlways
rows[].totalPricestringAlways
rows[].unitCostActualstringCan be null
rows[].unitCostDefaultstringCan be null
rows[].totalCostActualstringCan be null
rows[].totalCostDefaultstringCan be null
rows[].totalProfitsActualstringCan be null
rows[].totalProfitsDefaultstringCan be null
rows[].profitUnitActualstringCan be null
rows[].profitUnitDefaultstringCan be null
rows[].marginActualstringCan be null
rows[].marginDefaultstringCan be null
rows[].customFieldsobject[]Always
rows[].customFields[].keystringAlways
rows[].customFields[].labelstringAlways
rows[].customFields[].valuestringCan be null
What the AI reads

Cost of goods sold: one row per sold line item on a COMPLETED order that was not fully returned, with price, actual and default cost, profit and margin. Use for COGS, margins and profit per unit, product, category or brand. For line items without cost use distru-report-sales-orders with rowsPer LINE_ITEM; for sales totals per product use distru-report-sales-totals with rowsPer PRODUCT; for the cost of stock on hand use distru-report-inventory-assets. quantity is net of returns. *Actual uses the traced cost of the inputs that produced the stock; *Default values those inputs at their configured unit cost (the cost type's, else the product's). Cost, profit and margin are null when no cost can be traced; the margins also when totalPrice is 0. marginActual and marginDefault are fractions of totalPrice (0.25 is 25%). finalInput is always "Final" and costOrigin always null. batch is the package's batchNumber for a package-tracked item, else the Distru batch name with its batch number in parentheses when it has one. Sample lines are left out when the company excludes samples from cost reporting. Money, quantity and margin values 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.