# Export costs to DATEV

Write a month or a range of days as a DATEV Buchungsstapel that your tax advisor imports as it is, with your cost centres, projects and accounts.

The file has one row per month, cost centre, project and service, net of discounts and before VAT,
with each credit as a row of its own. Cents are distributed so that the rows add up exactly to the
net.

## Prerequisites

- Permission for `billing:GetCostAndUsage` to export.
- `billing:UpdateCostReportSettings` to set the DATEV fields, and `billing:GetCostReportSettings`
  to open **Reports & DATEV**.
- Your Beraternummer and Mandantennummer, from your tax advisor. DATEV imports a file only with
  them.

## Set the DATEV fields

**Console**
1. Open **Reports & DATEV**.
2. (Optional) For **Cost-centre tag (KOST1)**, enter the tag key whose value is the cost centre.
   Empty means `cost-center`.
3. (Optional) For **Expense account (Konto)** and **Creditor account (Gegenkonto)**, enter the
   accounts. Empty accounts stay empty for your tax advisor to fill in.
4. For **Beraternummer** and **Mandantennummer**, enter the numbers.
5. For **Fiscal year starts**, enter the first month of your fiscal year (1–12), and for **Account
   digits**, the length of your general-ledger accounts (4–8).
6. Choose **Save**.

**CLI**
```sh
dcloud billing cost-report update --accounting \
  '{"kost1TagKey":"cost-center","konto":"4964","datev":{"beraternummer":29098,"mandantennummer":55003,"fiscalYearStartMonth":1,"accountLength":4}}'
```

**API**
```http
PUT /billing/api/cost-report
{ "accounting": { "kost1TagKey": "cost-center", "konto": "4964",
  "datev": { "beraternummer": 29098, "mandantennummer": 55003, "fiscalYearStartMonth": 1, "accountLength": 4 } } }
```

## Export

**Console**
1. Open **Cost explorer** and choose the range (see [Explore costs](explore-costs.md)).
2. Choose **DATEV export**.

The file covers exactly the range on screen.

**CLI**
```sh
dcloud billing costs accounting-export --month 2026-10 > EXTF_Buchungsstapel.csv
```

**API**
```http
GET /billing/api/cost-explorer/accounting-export?month=2026-10
```

Give `month` (YYYY-MM), or `start` and `end` (YYYY-MM-DD, both included, UTC). `kost1TagKey`,
`konto` and `gegenkonto` override the settings for one export.

## Result

A DATEV-Format Buchungsstapel, named `EXTF_Buchungsstapel_<first day>_<last day>.csv`: the EXTF
header record (version 700, category 21, format 13) with your Berater- and Mandantennummer (empty
until set), the start of the fiscal year (January until you set **Fiscal year starts**) and the
account length (4 until you set **Account digits**), then the 125 standard columns, in
Windows-1252 with semicolons and decimal commas.

- `KOST1` is the value of the cost-centre tag, `KOST2` the project; a resource in two projects is
  split evenly between them.
- `Belegdatum` and `Leistungsdatum` are the last day of service in the month inside the range, never
  a day still to come. A month that is not over says "vorläufig" in the `Buchungstext`.
- `Konto` and `Gegenkonto` come from the settings unless the export overrides them.

## When the export is refused

- `400` "A DATEV Buchungsstapel covers one fiscal year; this range crosses into the one starting
  …. Export the two parts separately." for a range across two fiscal years.
- `400` "Give a month (YYYY-MM), or both start and end (YYYY-MM-DD)." without a month or both days,
  and also when `month` is given together with `start` or `end`.
- `400` "end is before start." for a reversed range.

## Related

- [Get the monthly cost report](get-the-monthly-cost-report.md)
- [Export costs](export-costs.md)
- `billing.costs.accounting-export` · `dcloud billing costs accounting-export`
