# Open items (חובות פתוחים)

`GET /businesses/{bid}/receivables`

Requires the `documents` scope.

Every issued invoice (305) and proforma (300) with a balance: what was paid against it, what was credited, what is left, how many days it has been open, in the four ageing buckets. A receipt that names the invoice (`settles`) is what closes it.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `partyId` | string |  | One customer. |
| `asOf` | string |  | Age as of this day (default today). |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `receivables` | Receivables | **required** | Every open invoice and proforma, aged from its due date when it states one and from its document date otherwise. |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X GET "$BASE/businesses/$BID/receivables?partyId=&asOf=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/receivables`, {
  method: 'GET',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.get(
    f"{BASE}/businesses/{BID}/receivables",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```