# DHL Express — Deklaracja eksportowa

[Dokumentacja DHL](<https://developer.dhl.com/api-reference/dhl-express-mydhl-api?language_content_entity=en#get-started-section/>)

W przypadku gdy nadawca lub odbiorca przesyłki są spoza EU, należy do requestu o zamówienie kuriera dołączyć Deklaracje Eksportowa (`DHLExportDeclarationDTO`). W deklaracji musimy podać ceny i wagi poszczególnych paczek.

Jeśli apollo będzie próbowało wysłać takie paczki (2 rzędy, w pierwszym rzędzie 5 paczek o wartości 5 EUR (za sztukę), w drugim rzędzie jedna paczka o wartości 1 EUR):

![Packages from apollo](<https://docs.logintegra.com/microservice-courier/images/3/dhl-express/packages-from-apollo.png>)

Jeśli będzie do nich wymagana deklaracja eksportowa (np.: transport z Niemiec do USA), MSC stworzy i wyśle następujący request do DHL:

```
{
  "plannedShippingDateAndTime": "2023-06-08T08:00:00GMT+00:00",
  "pickup": {
    "isRequested": true,
    "closeTime": "18:00",
    "pickupDetails": {
      "postalAddress": {
        "postalCode": "59929",
        "cityName": "Testowo",
        "countryCode": "DE",
        "addressLine1": "Testowa"
      },
      "contactInformation": {
        "phone": "+48123123123",
        "companyName": "Firma",
        "fullName": "6FAF22DDE",
        "email": "test@test.com"
      }
    }
  },
  "productCode": "P",
  "getRateEstimates": true,
  "accounts": [
    {
      "typeCode": "shipper",
      "number": "numer"
    }
  ],
  "valueAddedServices": [
    {
      "serviceCode": "WY"
    }
  ],
  "outputImageProperties": {
    "encodingFormat": "pdf",
    "imageOptions": [
      {
        "typeCode": "invoice",
        "invoiceType": "commercial",
        "isRequested": false
      },
      {
        "typeCode": "waybillDoc",
        "hideAccountNumber": false,
        "isRequested": true
      },
      {
        "typeCode": "label",
        "templateName": "ECOM26_84_001",
        "renderDHLLogo": true,
        "isRequested": true,
        "labelFreeText": "2222222"
      }
    ],
    "splitTransportAndWaybillDocLabels": true
  },
  "customerDetails": {
    "shipperDetails": {
      "postalAddress": {
        "postalCode": "59929",
        "cityName": "Testowo",
        "countryCode": "DE",
        "addressLine1": "Testowa"
      },
      "contactInformation": {
        "phone": "+48123123123",
        "companyName": "firma",
        "fullName": "6FAF22DDE",
        "email": "test@test.com"
      }
    },
    "receiverDetails": {
      "postalAddress": {
        "postalCode": "21401",
        "cityName": "NowoTestowo",
        "countryCode": "US",
        "addressLine1": "NowoTestowa"
      },
      "contactInformation": {
        "phone": "+48123123123",
        "companyName": "firma",
        "fullName": "6FAF22DDE",
        "email": "test@test.com"
      }
    }
  },
  "content": {
    "packages": [
      {
        "weight": 5.0,
        "dimensions": {
          "length": 5,
          "width": 5,
          "height": 5
        },
        "description": "Coś"
      },
      {
        "weight": 5.0,
        "dimensions": {
          "length": 5,
          "width": 5,
          "height": 5
        },
        "description": "Coś"
      },
      {
        "weight": 5.0,
        "dimensions": {
          "length": 5,
          "width": 5,
          "height": 5
        },
        "description": "Coś"
      },
      {
        "weight": 5.0,
        "dimensions": {
          "length": 5,
          "width": 5,
          "height": 5
        },
        "description": "Coś"
      },
      {
        "weight": 5.0,
        "dimensions": {
          "length": 5,
          "width": 5,
          "height": 5
        },
        "description": "Coś"
      },
      {
        "weight": 1.0,
        "dimensions": {
          "length": 1,
          "width": 1,
          "height": 1
        },
        "description": "Jedna mała rzecz"
      }
    ],
    "isCustomsDeclarable": true,
    "declaredValue": 26,
    "declaredValueCurrency": "EUR",
    "description": "Coś;Jedna mała rzecz",
    "incoterm": "DAP",
    "unitOfMeasurement": "metric",
    "exportDeclaration": {
      "lineItems": [
        {
          "number": 1,
          "description": "Coś",
          "price": 5.0,
          "quantity": {
            "value": 5,
            "unitOfMeasurement": "BOX"
          },
          "manufacturerCountry": "PL",
          "weight": {
            "netValue": 5.0,
            "grossValue": 5.0
          }
        },
        {
          "number": 2,
          "description": "Jedna mała rzecz",
          "price": 1.0,
          "quantity": {
            "value": 1,
            "unitOfMeasurement": "BOX"
          },
          "manufacturerCountry": "PL",
          "weight": {
            "netValue": 1.0,
            "grossValue": 1.0
          }
        }
      ],
      "invoice": {
        "number": "11111",
        "date": "2023-06-05"
      }
    }
  },
  "documentImages": [
    {
      "typeCode": "INV",
      "imageFormat": "PDF",
      "content": "<dlugi hash>"
    }
  ]
}
```

W węźle `exportDeclaration` w `quantity` podajemy ilość danych paczek, a `weight` oraz `price` podajemy wagę i cenę jednej sztuki. Ogólna wartość wysyłki jest widoczna w `declaredValue` (poza deklaracja eksportowa) i jest to suma iloczynów ilości i wartości paczek.
