# Reports & Queries

A family of **read-only API queries** (Business Central `QueryType = API`, `DataAccessIntent = ReadOnly`) that pre-join posted documents and ledger entries into flat reconciliation feeds. They exist so an eOne integration map can pull settlement, fulfillment, and stock data in a single round-trip instead of stitching together several master/document endpoints. None of them insert, update, or expose bound actions. They are pull-only.

> **Note:** These are **OData queries**, not entity pages. Their JSON column names are **PascalCase** (e.g. `ShipHeaderIntegrationId`, `TotalPayments`), taken from each query column's name, unlike the camelCase fields on the writable endpoints. There is no `id`/`SystemId` envelope and no `$expand`; the join is baked into the query.

> **Caution:** Query columns are the published contract for live eOne integration maps. Renaming a column is a breaking change. Each query also has fixed `DataItemTableFilter`s (e.g. payments filtered to `Document Type = Payment`, line feeds filtered to `Type = Item`). Rows that do not match are absent, not empty.

## Why these are queries, not pages

Each feed answers a reconciliation question that spans two or more tables. The payments queries sum every payment applied to an invoice via a `Method = Sum` aggregate column (`TotalPayments`), which an entity page cannot express. The posted-document feeds carry the originating store's key on both the header and the line: `...HeaderIntegrationId` is mirrored from the active document's [Integration Id](https://eonesolutions.github.io/eone-bc-integration/integration-id.md) at post time, and `...LineIntegrationId` is carried onto the posted line. So the consumer can match a shipment or receipt back to the order it requested without a second lookup.

Location keys are resolved inline too: where a feed reports a `Location Code`, it left-joins [Location](https://eonesolutions.github.io/eone-bc-integration/core-locations.md) to also surface that location's Integration Id. These are all [posted documents](https://eonesolutions.github.io/eone-bc-integration/posted-documents.md), immutable once written, which is why the whole family is read-only.

## The queries

| Entity set | Reports / joins |
| --- | --- |
| `salesCreditMemosQuery` | Posted sales credit memo lines joined to the originating posted sales invoice (via item ledger application), for reconciling returns and refunds against the original order. Carries credit-memo, invoice, and line Integration Ids. Filterable by credit memo number, customer, posting date. |
| `salesShipmentsQuery` | Posted sales shipment lines (Type = Item) with header tracking + full Ship-to address block: package tracking number, shipping agent/service and the agent's tracking-URL template, shipment/delivery dates, sell-to customer. For pushing fulfillment and tracking back to a channel. Filterable by order, shipment, customer, item, variant, location, shipment date. Need a push instead of a pull? Use the [salesShipments](https://eonesolutions.github.io/eone-bc-integration/core-salesShipments.md) page (webhook-enabled). |
| `customerPaymentsQuery` | Customer payment ledger entries (Document Type = Payment) matched to the sales invoices they settle, plus a `TotalPayments` sum applied per invoice. For tracking order payment status. See also [Customer Payments](https://eonesolutions.github.io/eone-bc-integration/core-customerPayments.md). Filterable by customer, document number, posting date. |
| `vendorPaymentsQuery` | AP-side counterpart: vendor payment ledger entries matched to the purchase invoices they settle, with the per-invoice `TotalPayments` sum. Filterable by vendor, document number, posting date. |
| `itemInventoryLevelQuantitiesByLocationQuery` | On-hand quantity (summed item ledger) per item broken down by location, with item attributes (type, blocked, sales blocked, replenishment system, assembly policy) and both Location and Item Integration Ids. For publishing stock availability to a store. Filterable by item number, location code. **Always on**: aggregates the ledger on each call; kept for existing maps. |
| `itemAvailabilitiesByLocationQuery` | **Faster successor** to the inventory-level query: same item-by-location shape and attributes, but read from the pre-aggregated [Item Availability](https://eonesolutions.github.io/eone-bc-integration/core-itemInventoryAvailabilities.md) snapshot instead of summing the ledger, so it scales far better for frequent polling. Adds reserved, safety-stock, qty-on-purchase-order and a pre-netted `AvailableQuantity`, and reflects the eOne Integration Setup options (granularity, formula, inclusion filters). Returns data only while Item Availability is enabled. Prefer this for new integrations. Filterable by item number, location code. |
| `transferShipmentsQuery` | Posted transfer shipment lines + header (transfer order number, from/to locations, in-transit code, dates) for reconciling inter-location movements that have shipped. Header and line Integration Ids plus from/to location Ids. Filterable by transfer order, shipment, item, variant, location. |
| `transferReceiptsQuery` | Posted transfer receipt lines + header, confirming inter-location stock has arrived at the destination. Same key/location shape as transfer shipments. Filterable by transfer order, receipt, item, variant, location. |
| `purchaseReceiptsQuery` | AP-side counterpart of sales shipments: posted purchase receipt lines (Type = Item) + header (purchase order, buy-from/pay-to vendor, vendor shipment number, dates) confirming goods receipt against a PO. Header/line Integration Ids and location Id. Filterable by order, receipt, vendor, item, variant, location. Need a push instead of a pull? Use the [purchaseReceipts](https://eonesolutions.github.io/eone-bc-integration/core-purchaseReceipts.md) page (webhook-enabled). |
| `purchaseCreditMemosQuery` | AP-side counterpart of sales credit memos: posted purchase credit memo lines (Type = Item) + header (buy-from/pay-to vendor, vendor credit memo number, dates) for reconciling supplier credits. Header and line Integration Ids. Filterable by credit memo number, vendor, item, posting date. |
| `archivedSalesDocumentsQuery` | Sales documents archived through the [archive or cancel](https://eonesolutions.github.io/eone-bc-integration/archive.md) actions, across all document types: read from the sales archive, filtered to the rows this extension created. One row per archived version (`versionNo` = revision number), with a `cancelled` flag, archived date/time and the original [Integration Id](https://eonesolutions.github.io/eone-bc-integration/integration-id.md). Filterable by document type, number, cancelled, integrationId. |
| `archivedPurchaseDocumentsQuery` | Purchase-side counterpart: purchase documents archived through the [archive or cancel](https://eonesolutions.github.io/eone-bc-integration/archive.md) actions, across all document types. Same shape (document type, number, versionNo, cancelled, archived date/time, Integration Id). Filterable by document type, number, buy-from vendor, integrationId. |
