diff --git a/classes/Carrier/SendCloud/Data/ParcelCreation.php b/classes/Carrier/SendCloud/Data/ParcelCreation.php index d4014b17..174361b6 100644 --- a/classes/Carrier/SendCloud/Data/ParcelCreation.php +++ b/classes/Carrier/SendCloud/Data/ParcelCreation.php @@ -12,8 +12,9 @@ class ParcelCreation extends ParcelBase { public ?int $SenderAddressId = null; - public function toApiRequest(): array { - return [ + public function toApiRequest(): array + { + $data = [ 'name' => $this->Name, 'company_name' => $this->CompanyName, 'address' => $this->Address, @@ -32,16 +33,19 @@ class ParcelCreation extends ParcelBase 'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null), 'country_state' => $this->CountryState, 'sender_address' => $this->SenderAddressId, - 'customs_invoice_nr' => $this->CustomsInvoiceNr, - 'customs_shipment_type' => $this->CustomsShipmentType, 'external_reference' => $this->ExternalReference, 'total_insured_value' => $this->TotalInsuredValue ?? 0, - 'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems), + 'parcel_items' => array_map(fn(ParcelItem $item) => $item->toApiRequest(), $this->ParcelItems), 'is_return' => $this->IsReturn, 'length' => $this->Length, 'width' => $this->Width, 'height' => $this->Height, ]; - } + if ($this->CustomsInvoiceNr !== null) + $data['customs_invoice_nr'] = $this->CustomsInvoiceNr; + if ($this->CustomsShipmentType !== null) + $data['customs_shipment_type'] = $this->CustomsShipmentType; + return $data; + } } \ No newline at end of file diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 4e4ebe03..2f7082e1 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -107,7 +107,7 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->CountryState = $json->state; $parcel->TotalInsuredValue = $json->total_insured_value; $parcel->OrderNumber = $json->order_number; - if (!empty($json->shipment_type)) { + if (!$this->app->erp->IstEU($json->country)) { $parcel->CustomsInvoiceNr = $json->invoice_number; $parcel->CustomsShipmentType = $json->shipment_type; foreach ($json->positions as $pos) {