Stock exports and reporting
Read stock costing defaults
/a/Stock_getCosts
Read cost, nominal code, numeric tax rate and scalar supplier defaults for one stock item.
When to use this endpoint
Use when selecting a stock item for a requisition-order line. Resolve a tax category name separately; this does not return taxtype.
Authentication and permissions
Authenticate through the dispatcher with signed API-key fields or a CRM session. The handler requires login and tenant context (DBP) but has no explicit stock, export or finance permission check.
Query is scoped to the authenticated tenant. Session CSRF and API signing still apply.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible string | Yes | Missing or negative integer conversion is rejected. A falsey input such as 0/'0'/blank gets no stock id provided. A truthy non-numeric value can pass and query ID zero. |
Example request
$costs = FM_api('Stock_getCosts', ['id'=>'1042']);
Example response
{"average_cost":"4.5","nominal_code":"4000","tax_rate":"20.00","supplier_id":"2042","supplier_name":"Parts supplier"}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: id"} | ID is missing or integer-converts below zero. |
{"error":"no stock id provided"} | The supplied ID is PHP-falsey. |
false | No matching row or database read failure. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Requires login and tenant context DBP; no additional stock/export/finance page permission is enforced. Excludes deleted stock but includes archived stock and retained deleted supplier labels.
- Returns a single database row or false for no match/read failure. Supplier name can be null when its left join does not match. Database numeric fields remain strings/null.
- No selling price, tax type name, field projection or stock movement is returned.
- No stock quantity, audit, edit timestamp, notification or event is changed. Reads across multiple queries are not a transactionally frozen snapshot.
- No paging/search option or result wrapper is implemented; the output is JSON, not CSV.
- No direct caller for this exact endpoint was found in the current app JavaScript or
m/wwwintermediary; these are office reporting/source-selection calls, not the app download protocol.
Side effects
- Read-only; does not create a CSV file, mutate stock or run configured events.
See it in Fieldmotion
CRM1
Open a Requisition Order, add/select a stock line, and filter Network for Stock_getCosts. The caller loads supplier, average cost, nominal and tax_rate, then resolves tax options; explicit tax_rate=0 is retained.
CRM2
No direct CRM2 caller was found; the Stocks module uses mapped stock detail APIs.
Related endpoints
Stock_exportSummaryprovides the CSV destination-type summary.Stock_exportCostsprovides tenant-wide valuation totals.Stock_getNamesresolves catalog labels.