## Open billing units outside projects and recent batches (hr:work:billing)

`GET /api/hr/v1/work-billing`

Module: HR · operationId: `getWorkBilling` · Tag: Work billing · Auth: access token (`Authorization: Bearer <accessToken>`)

The contracts and customers with approved billable work outside projects that no batch holds (`openEntries`,
`openMinutes` – hourly minutes only) or with entries waiting for approval (`unapproved`), and the newest 100
contract and customer batches.

### Responses

- **200** Units and batches (`application/json`)
- **403** Error (`application/json`)

Fields of the 200 answer:

- `batches` (array of WorkBatch): The newest 100 contract and customer batches
  - `billableMinutes` (integer): Hourly minutes (flat-rate entries are not counted)
  - `contractId` (string): Trade contract of contract batches
  - `createdAt` (string (date-time)): When the batch was created
  - `customerId` (string): Customer (masterdata address id) of contract and customer batches
  - `entryCount` (integer): Number of entries in the batch
  - `grossTotal` (number, nullable): Gross total of trade's invoice
  - `id` (string (uuid)): Id of the batch
  - `invoiceNumber` (string): Given by trade on release
  - `invoicedOn` (string (date), nullable): Date of the invoice (YYYY-MM-DD) once released
  - `label` (string): Names the unit on the invoice and in lists
  - `lastError` (string): Why the last send failed (German)
  - `netAmount` (number): Net amount HR computed
  - `netTotal` (number, nullable): Net total of trade's invoice
  - `periodFrom` (string (date)): First work day of the period (YYYY-MM-DD)
  - `periodTo` (string (date)): Last work day of the period (YYYY-MM-DD)
  - `projectRef` (string): Reference of the project (project batches)
  - `requestedAt` (string (date-time)): When the batch was requested
  - `requestedBy` (string): Who requested it (e-mail)
  - `scope` (string): Billing unit of the batch (one of `project`, `contract`, `customer`)
  - `sendAttempts` (integer): Attempts to send the draft to trade
  - `state` (string): requested → drafted (trade holds the draft) → invoiced; discarded: the draft was deleted, the entries are free again (one of `requested`, `drafted`, `invoiced`, `discarded`)
  - `tradeTransactionId` (string): Id of trade's document
  - `updatedAt` (string (date-time)): When the batch was last changed
  - `version` (integer): Version for optimistic locking: send the version you read with a change (stale: 409 version_conflict)
- `units` (array of object): Contracts and customers with open billable work outside projects
  - `contractId` (string): Trade contract (contract units)
  - `contractNumber` (string): Number of the contract
  - `contractTitle` (string): Title of the contract
  - `customerId` (string): Customer (masterdata address id)
  - `customerName` (string): Name of the customer
  - `firstOpen` (string): First work day (YYYY-MM-DD) of the approved open entries; empty when the unit has only unapproved ones
  - `lastOpen` (string): Last work day (YYYY-MM-DD) of the approved open entries; empty when the unit has only unapproved ones
  - `openEntries` (integer): Approved billable entries no batch holds
  - `openMinutes` (integer): Hourly minutes of those entries
  - `scope` (string): Billing unit (one of `contract`, `customer`)
  - `unapproved` (integer): Entries waiting for approval

Example 200 answer:

```json
{
  "batches": [
    {
      "billableMinutes": 270,
      "createdAt": "2026-11-03T10:15:00Z",
      "customerId": "1b3d5f7b-9d1f-4b3d-8f5b-9d1f3b5d7f50",
      "entryCount": 2,
      "id": "1f3b5d7f-9b1d-4f3b-8d7f-9b1d3f5b7d61",
      "label": "Kanzlei Hofmann \u0026 Partner",
      "netAmount": 427.5,
      "periodFrom": "2026-10-01",
      "periodTo": "2026-10-31",
      "requestedAt": "2026-11-03T10:15:00Z",
      "requestedBy": "christina.adler@muster-it.example",
      "scope": "customer",
      "sendAttempts": 1,
      "state": "drafted",
      "tradeTransactionId": "3b5d7f9b-1d3f-4b5d-9f9b-1d3f5b7d9f62",
      "updatedAt": "2026-11-03T10:15:04Z",
      "version": 2
    }
  ],
  "units": [
    {
      "customerId": "1b3d5f7b-9d1f-4b3d-8f5b-9d1f3b5d7f50",
      "customerName": "Kanzlei Hofmann \u0026 Partner",
      "firstOpen": "2026-11-02",
      "lastOpen": "2026-11-17",
      "openEntries": 5,
      "openMinutes": 225,
      "scope": "customer",
      "unapproved": 1
    },
    {
      "contractId": "7a9c1e3a-5c7e-4a9c-8e3a-5c7e9a1c3e52",
      "contractNumber": "WV-2026-0007",
      "contractTitle": "Wartungsvertrag Netzwerk und WLAN",
      "customerId": "3c5e7a9c-1d3f-4b5a-9c7e-1a3c5e7a9c1e",
      "customerName": "Alpenhotel Seeblick GmbH",
      "firstOpen": "2026-11-04",
      "lastOpen": "2026-11-16",
      "openEntries": 2,
      "openMinutes": 0,
      "scope": "contract",
      "unapproved": 0
    }
  ]
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/hr/v1/work-billing' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
