# Run fees for a period and produce draft invoices

`POST /lokta-lms/api/v1/fee-runs`

Computes partner fees for a period and produces a draft invoice for each partner and currency.

Walks every attributed loan, finds the agreement in force for that loan's product, and accrues each fee line for the uncovered day-ranges of the period (a live accrual for the same loan+line covers its days). Then produces one draft invoice per partner+currency with a non-zero amount, each carrying a tracking number, the per-line basis with the terms version, and an identity snapshot. A rerun tops up late attributions; nothing is superseded or refused for overlap. A zero amount produces no draft.

Requires an `Idempotency-Key`; a replayed compute would double a partner's earnings for a period.

## When to use it

Run this at the end of a period to compute partner fees from attributed loans and produce a draft invoice for each partner and currency.

## Worth knowing
- Send an Idempotency-Key header. A replayed compute would double a partner's earnings for the period.
- A rerun tops up late attributions. It does not fail on overlap.

## Parameters
- `Idempotency-Key` (header, string): Per-intent key

## Request body (application/json)
- `period_start` (string): Placeholder name, to be confirmed. The first day of the period to compute.
- `period_end` (string): Placeholder name, to be confirmed. The last day of the period to compute.

## Responses
- `default`: default response

## Example request (cURL)
```bash
curl -X POST \
  'https://default.lokta.tech/lokta-lms/api/v1/fee-runs' \
  -u '{username}:{password}' \
  -H 'Tenant-Identifier: default' \
  -H 'Content-Type: application/json' \
  -d '{
  "period_start": "string",
  "period_end": "string"
}'
```

Interactive: https://developer.lokta.ai/reference#operation/compute
