> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maesn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DATEV Rechnungswesen Technical Reference

> Technical insights and DATEV-specific field explanations for data retrieval endpoints

## GET /accounts - Account functions

This endpoint retrieves general ledger accounts as well as customer and supplier accounts from DATEV Rechnungswesen.

The maesn API maps the account number and description to the unified model. Since some fields returned by DATEV are DATEV-specific, they are not mapped to the unified model. However, they are still available in the raw response when using `rawData=true`.

### DATEV-specific fields

The three DATEV-specific fields are:

* **mainFunction**: the function type
* **mainFunctionNumber**: the function number
* **functionExtension**: the additional detail or extension

These fields are part of DATEV's account-function model for SKR03 and SKR04. In addition to the account number and caption, DATEV can assign an account function to an account. This account function provides additional classification information that helps describe how the account is categorized within DATEV's bookkeeping logic.

In the API response, this account function is represented by the fields `mainFunction`, `mainFunctionNumber`, and `functionExtension`.

### Interpreting account functions

To help interpret these values, DATEV publishes yearly [Kontenfunktions-Tabellen for SKR03 and SKR04](https://help-center.apps.datev.de/api/amr/knowledge-common/v1/entities/st63880273803_de.xlsx). These tables list the available account functions for a given year and provide the reference needed to understand the values returned in the API.

DATEV account-function tables use the format `ZZ YY XXX`, where:

* `ZZ` = function type
* `YY` = main function number
* `XXX` = function extension

In the API response, `mainFunction` corresponds to the function type (`ZZ`), `mainFunctionNumber` to the main function number (`YY`), and `functionExtension` to the function extension (`XXX`).

### Main function values

The following `mainFunction` values are relevant:

* `0` = no type
* `1` = automatic input tax invoice (`AV`)
* `2` = automatic VAT invoice (`AM`)
* `3` = general function (`F`)
* `4` = collective function (`S`)
* `6` = collective function, automatic input tax (`SAV`)
* `7` = collective function, automatic VAT (`SAM`)
* `8` = standard function deactivated

## GET /journalEntries and GET /trialBalance - Accounting reasons

When working with journal entries and trial balance data from DATEV Rechnungswesen, you may notice calculation discrepancies between the two datasets.
This is because the two endpoints have a different data scope: journal entries cover all accounting areas, while the trial balance is restricted to a single accounting area (see below).

These sections first explain the underlying DATEV concept (accounting areas), and then how this concept affects the data returned by the API.

### Background: DATEV accounting areas

This section describes how accounting areas work inside DATEV Rechnungswesen itself — independent of the API.

Accounting reasons (Rechnungslegungszwecke) allow journal entries to be assigned to different accounting areas (Bereiche). Common use cases include:

* **Commercial law** (Handelsrecht)
* **Tax law** (Steuerrecht)
* **IFRS**
* **Other specialized accounting purposes**

In DATEV, the accounting area is not assigned per individual entry, but on the journal entry batch (Buchungsstapel): when creating a batch, the user chooses whether it belongs to a specific area or to all areas. Every journal entry in the batch belongs to that area accordingly.

Areas are configured per client in DATEV Rechnungswesen (under "Bereiche verwalten"). In the standard configuration, accounting area 1 is **commercial law** — but users can rename or redefine areas ([see DATEV Hilfe-Dokument 9226437](https://wissensplattform.apps.datev.de/help/document/9226437)), so the meaning of each area can differ from client to client.

### API data scope: What each endpoint returns

This section describes how the accounting areas above determine which data the API endpoints return.

In the API, the journal entries batch is represented as an accounting sequence.
Each journal entry references its batch through the `accountingSequenceId` and it exposes the accounting area via the `accountingReason` field.

**Important**

1. The `accounting_sequence_id` and `accountingReason` are DATEV-specific field. They are not currently mapped to the unified model and are available in the raw response of `GET /journalEntries` (`GET /asyncTask`) when using `rawData=true`.
2. The `GET /trialBalance` response, in contrast, contains no accounting area or `accountingReason` fields at all: the amounts it returns are already implicitly restricted to accounting area 1 by DATEV. This restriction is applied before the data is returned and can neither be observed in the response nor changed via a request parameter

**Trial Balance (`GET /trialBalance`)**:

* Provides aggregated sums and balances per account
* These values are calculated exclusively from journal entries assigned to **accounting area 1 (Bereich 1)** — in the DATEV standard configuration, this is **commercial law** (Handelsrecht)
* However, users can rename or redefine accounting areas in DATEV Rechnungswesen ([see DATEV Hilfe-Dokument 9226437](https://wissensplattform.apps.datev.de/help/document/9226437). In that case, the trial balance still returns area 1, but area 1 may then represent tax law, calculation, or a custom-defined area

**Journal Entries (`GET /journalEntries`)**:

* Returns **all** journal entries, regardless of their accounting reason
* Provides detailed transaction-level data

See also DATEV's documentation: [accounting:dataexchange – Information on further processing of data](https://developer.datev.de/de/product-detail/accounting-dataexchange/1/documentation/information-on-further-processing-of-data)

### Available accounting reasons

The following `accountingReason` values are possible:

* `commercial_law` - Commercial/financial accounting (Handelsrecht)
* `tax_law` - Tax accounting (Steuerrecht)
* `ifrs` - International Financial Reporting Standards
* `reserved1` - Reserved for future use
* `reserved2` - Reserved for future use
* `for_calculation` - For calculation purposes
* `independent_from_accounting_reason` - Independent from accounting reason

### Calculate trial balance for target account number using GET /journalEntries

While you can retrieve trial balance data directly using the `GET /trialBalance` endpoint, you may want to verify or double-check the balance for a specific account number. To do this using journal entries:

**Verification workflow** (assumes the DATEV standard configuration, where area 1 = commercial law):

1. Retrieve all journal entries using `GET /journalEntries` and `GET /asyncTask` with `rawData=true`
2. Filter entries for your target account number
3. From the raw data, access the `accountingReason` field attached to each journal entry
4. Select only entries with `accountingReason` equal to `commercial_law`
5. Calculate the total for these filtered entries

This manual calculation should match the trial balance for that account, **as long as the client uses the DATEV standard area configuration**.

**Limitations:**

* If the client has redefined accounting area 1 (e.g. to tax law, calculation, or a custom area), the trial balance reflects that redefined area. In this case, filter on the `accountingReason` that corresponds to the client's area 1 instead of `commercial_law`
