## Compare purchase and sales of a month per provider (tenant:trade:msp:read)

`GET /api/trade/v1/msp/reconciliation`

Module: Trade · operationId: `getMspReconciliation` · Tag: MSP billing · Auth: access token (`Authorization: Bearer <accessToken>`)

Per provider the inbound invoices of its supplier whose service date (delivery date, else document date) lies
in the month against the MSP invoice lines of the month, per SKU; the supplier is the provider's
`supplierAddressId` in the MSP configuration, else the address masterdata links with the distributor id of the
provider. `backToBack` gives the month's margin of every back-to-back link (MSP sales of the customer contract
against the monthly share of the supplier contract's net amount).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `month` | query | string |  | Billing month `YYYY-MM` (Europe/Berlin); default the previous month. |

### Responses

- **200** Reconciliation (`application/json`)
- **400** Error (`application/json`)
- **401** No valid session or bearer token (no body).
- **403** Missing permission, no active tenant in the token, or a missing CSRF token on a cookie write. (`application/json`)
- **503** The configuration store is not available. (`application/json`)

Fields of the 200 answer:

- `backToBack` (array of object): Sales and purchase per back-to-back link.
  - `customerContractId` (string (uuid)): Id of the customer contract.
  - `customerContractNumber` (string): Number of the customer contract.
  - `linkId` (string (uuid)): Id of the back-to-back link.
  - `margin` (number): Sales minus purchase.
  - `purchaseNet` (number): Net purchase.
  - `salesNet` (number): Net sales.
  - `supplierContractId` (string (uuid)): Id of the supplier contract.
  - `supplierContractNumber` (string): Number of the supplier contract.
- `month` (integer): Month (1–12) of the billing month.
- `providers` (array of object): Purchase and sales per provider.
  - `margin` (number): Sales minus purchase.
  - `problem` (string): Why the purchase side is missing.
  - `provider` (string): MSP provider (`mailstore`, `sophos`, `ingram`, `itc`, …).
  - `purchaseInvoices` (array of object): Inbound invoices of the supplier in the month.
    - `documentDate` (string (date-time)): Invoice date.
    - `id` (string (uuid)): Id of the purchase invoice.
    - `netTotal` (number): Net total.
    - `supplierInvoiceNumber` (string): The supplier's invoice number.
    - `transactionNumber` (string): Number of the inbound invoice.
  - `purchaseNet` (number): Net purchase of the month.
  - `salesBookedNet` (number): Booked MSP invoices only.
  - `salesNet` (number): All MSP invoices of the month, drafts included.
  - `skus` (array of object): Purchase and sales per SKU.
    - `purchasedNet` (number): Net purchase.
    - `purchasedQuantity` (number): Quantity purchased.
    - `sku` (string): The provider's SKU.
    - `soldNet` (number): Net sales.
    - `soldQuantity` (number): Quantity sold.
  - `supplier` (object): Supplier address of the provider.
    - `addressId` (string): Masterdata address of the supplier.
    - `name` (string): Name of the supplier.
- `year` (integer): Year of the billing month.

Example 200 answer:

```json
{
  "backToBack": [
    {
      "customerContractId": "0e1f2a3b-4c5d-4e6f-8a7b-9c0d1e2f3a07",
      "customerContractNumber": "V-2026-0007",
      "linkId": "6b7c8d9e-0f1a-4b2c-9d3e-4f5a6b7c8d01",
      "margin": 101,
      "purchaseNet": 79,
      "salesNet": 180,
      "supplierContractId": "0e1f2a3b-4c5d-4e6f-8a7b-9c0d1e2f3a03",
      "supplierContractNumber": "LV-2026-0003"
    }
  ],
  "month": 10,
  "providers": [
    {
      "margin": 321.8,
      "provider": "ingram",
      "purchaseInvoices": [
        {
          "documentDate": "2026-11-02T00:00:00Z",
          "id": "8e1f2a3b-4c5d-4e6f-9a7b-0c1d2e3f4a21",
          "netTotal": 1617.2,
          "supplierInvoiceNumber": "6010009876",
          "transactionNumber": "ER-2026-00041"
        }
      ],
      "purchaseNet": 1617.2,
      "salesBookedNet": 0,
      "salesNet": 1939,
      "skus": [
        {
          "purchasedNet": 499.2,
          "purchasedQuantity": 48,
          "sku": "CFQ7TTC0LDPB:0001/P1YM",
          "soldNet": 600,
          "soldQuantity": 48
        },
        {
          "purchasedNet": 1118,
          "purchasedQuantity": 65,
          "sku": "CFQ7TTC0LCHC:0002/P1YM",
          "soldNet": 1339,
          "soldQuantity": 65
        }
      ],
      "supplier": {
        "addressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d10",
        "name": "Ingram Micro Distribution GmbH"
      }
    },
    {
      "margin": 471.6,
      "problem": "Für Oktober 2026 liegt noch keine Eingangsrechnung des Lieferanten vor.",
      "provider": "itc",
      "purchaseInvoices": [],
      "purchaseNet": 0,
      "salesBookedNet": 0,
      "salesNet": 471.6,
      "skus": [],
      "supplier": {
        "addressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d03",
        "name": "CloudNine Hosting AG"
      }
    }
  ],
  "year": 2026
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/trade/v1/msp/reconciliation' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
