Skip to content

Commit 03f51a5

Browse files
author
Andreas Palm
committed
Sendcloud: handle field requirement/null for parcels without customs declaration
1 parent b6c2339 commit 03f51a5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

classes/Carrier/SendCloud/Data/ParcelCreation.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class ParcelCreation extends ParcelBase
1212
{
1313
public ?int $SenderAddressId = null;
1414

15-
public function toApiRequest(): array {
16-
return [
15+
public function toApiRequest(): array
16+
{
17+
$data = [
1718
'name' => $this->Name,
1819
'company_name' => $this->CompanyName,
1920
'address' => $this->Address,
@@ -32,16 +33,19 @@ public function toApiRequest(): array {
3233
'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null),
3334
'country_state' => $this->CountryState,
3435
'sender_address' => $this->SenderAddressId,
35-
'customs_invoice_nr' => $this->CustomsInvoiceNr,
36-
'customs_shipment_type' => $this->CustomsShipmentType,
3736
'external_reference' => $this->ExternalReference,
3837
'total_insured_value' => $this->TotalInsuredValue ?? 0,
39-
'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems),
38+
'parcel_items' => array_map(fn(ParcelItem $item) => $item->toApiRequest(), $this->ParcelItems),
4039
'is_return' => $this->IsReturn,
4140
'length' => $this->Length,
4241
'width' => $this->Width,
4342
'height' => $this->Height,
4443
];
45-
}
44+
if ($this->CustomsInvoiceNr !== null)
45+
$data['customs_invoice_nr'] = $this->CustomsInvoiceNr;
46+
if ($this->CustomsShipmentType !== null)
47+
$data['customs_shipment_type'] = $this->CustomsShipmentType;
4648

49+
return $data;
50+
}
4751
}

www/lib/versandarten/sendcloud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function CreateShipment(object $json, array $address): CreateShipmentResu
107107
$parcel->CountryState = $json->state;
108108
$parcel->TotalInsuredValue = $json->total_insured_value;
109109
$parcel->OrderNumber = $json->order_number;
110-
if (!empty($json->shipment_type)) {
110+
if (!$this->app->erp->IstEU($json->country)) {
111111
$parcel->CustomsInvoiceNr = $json->invoice_number;
112112
$parcel->CustomsShipmentType = $json->shipment_type;
113113
foreach ($json->positions as $pos) {

0 commit comments

Comments
 (0)