> For the complete documentation index, see [llms.txt](https://docs.solutioo.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solutioo.de/entwicklerdokumentationen-business-central-dhl-connector/dhl-connector-entwicklerdokumentation/architektur-und-prozessflusse/tarifimport-und-preisberechnung.md).

# Tarifimport und Preisberechnung

Der lokale Rate Provider ist unabhängig vom Live-Express-Endpoint. Er berechnet Preise aus versionierten DHL-Vertragstarifen in Business Central.

## Importfluss

```mermaid
flowchart LR
  X[Excel Workbook] --> B[Import Batch]
  B --> S[Import Lines / Staging]
  S --> V[ValidateBatch]
  V -->|Fehler| E[Status Error]
  V -->|OK| A[ActivateBatch]
  A --> M[Tarif-Stammdaten]
  M --> T[Status Active]
```

Sieben Sheets werden erwartet:

* `PRICE_LISTS`
* `PRODUCTS`
* `ZONES`
* `DESTINATIONS`
* `RATES`
* `SURCHARGES`
* `INDEX_VALUES`

Die Validierung prüft Pflicht-Sheets, Spalten, Werte, Formate und Referenzen. Fehler bleiben als Import Lines mit Fehlercode und Text nachvollziehbar.

## Aktivierung

Eine validierte Version wird in die Tarifstammdaten übertragen. Eine bereits aktive identische Version darf nicht ersetzt werden. Beim Aktivieren werden zeitlich überlappende aktive Versionen desselben Tarifs und Billing Accounts archiviert.

## Berechnungsfluss

1. Datum und Länder normalisieren.
2. aktiven, gültigen Tarif wählen.
3. kontospezifischen Tarif gegenüber generischem Tarif bevorzugen.
4. Produkt ermitteln.
5. Zielzone über Land, Postcode, Datum und Priorität bestimmen.
6. Volumengewicht und abrechenbares Gewicht berechnen.
7. passendste Rate auswählen; länderspezifisch schlägt Zone.
8. Basismethode anwenden.
9. Pflicht- und Servicezuschläge berechnen.
10. Summary und Detailzeilen in den temporären Result Buffer schreiben.

## Fehlervertrag

Der Provider wirft für fachlich erwartbare Berechnungsfehler keinen AL-Fehler, sondern liefert `false`, `ErrorCode`, `ErrorText` und eine Information-Zeile. Typische Codes sind:

* `INVALID_WEIGHT`
* `DESTINATION_REQUIRED`
* `TARIFF_NOT_FOUND`
* `ZONE_NOT_FOUND`
* `MAX_WEIGHT_EXCEEDED`
* `RATE_NOT_FOUND`

## Ergebnis

Die Summary-Zeile enthält Tarif, Version, Zone, tatsächliches, Volumen- und abrechenbares Gewicht sowie Basis-, Zuschlags- und Gesamtbetrag. Weitere Zeilen dokumentieren Basistarif und einzelne Zuschläge.

## Externe Verwendung

Abhängige Apps sollen ausschließlich `SOUDHL Rate Provider.CalculateRate` verwenden. Direkte Tarif-Tabellenzugriffe sind nur für Administration oder ausdrücklich abgestimmte Adapter geeignet.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.solutioo.de/entwicklerdokumentationen-business-central-dhl-connector/dhl-connector-entwicklerdokumentation/architektur-und-prozessflusse/tarifimport-und-preisberechnung.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
