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/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 9fcd29ee..44743e27 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -409,8 +409,11 @@ abstract class Versanddienstleister $products = array_combine(array_column($products, 'Id'), $products); $address['product'] = $products[0]->Id ?? ''; + $countries = $this->app->DB->SelectArr("SELECT iso, bezeichnung_de name, eu FROM laender ORDER BY bezeichnung_de"); + $countries = array_combine(array_column($countries, 'iso'), $countries); + $json['form'] = $address; - $json['countries'] = $this->app->erp->GetSelectLaenderliste(); + $json['countries'] = $countries; $json['products'] = $products; $json['customs_shipment_types'] = [ CustomsInfo::CUSTOMS_TYPE_GIFT => 'Geschenk', diff --git a/www/lib/versandarten/content/createshipment.tpl b/www/lib/versandarten/content/createshipment.tpl index 04d3f8e1..3ece01dd 100644 --- a/www/lib/versandarten/content/createshipment.tpl +++ b/www/lib/versandarten/content/createshipment.tpl @@ -73,7 +73,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Land|}: @@ -156,7 +156,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Produkt|}: @@ -170,29 +170,33 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1

{|Bestellung|}

- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}: - -
{|Versicherungssumme|}:
{|Bestellnummer|}:
{|Versicherungssumme|}:
{|Rechnungsnummer|}:
{|Sendungsart|}: + +
-
+
@@ -269,10 +273,30 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 deletePosition: function (index) { this.form.positions.splice(index, 1); }, + productAvailable: function (product) { + if (product == undefined) + return false; + if (product.WeightMin > this.form.weight || product.WeightMax < this.form.weight) + return false; + return true; + }, serviceAvailable: function (service) { if (!this.products.hasOwnProperty(this.form.product)) return false; return this.products[this.form.product].AvailableServices.indexOf(service) >= 0; + }, + customsRequired: function () { + return this.countries[this.form.country].eu == '0'; + } + }, + beforeUpdate: function () { + if (!this.productAvailable(this.products[this.form.product])) { + for (prod in this.products) { + if (!this.productAvailable(this.products[prod])) + continue; + this.form.product = prod; + break; + } } } }) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 2216cb83..cdda1cce 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -105,19 +105,21 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->EMail = $json->email; $parcel->Telephone = $json->phone; $parcel->CountryState = $json->state; - $parcel->CustomsInvoiceNr = $json->invoice_number; - $parcel->CustomsShipmentType = $json->shipment_type; $parcel->TotalInsuredValue = $json->total_insured_value; $parcel->OrderNumber = $json->order_number; - foreach ($json->positions as $pos) { - $item = new ParcelItem(); - $item->HsCode = $pos->zolltarifnummer; - $item->Description = $pos->bezeichnung; - $item->Quantity = $pos->menge; - $item->OriginCountry = $pos->herkunftsland; - $item->Price = $pos->zolleinzelwert; - $item->Weight = $pos->zolleinzelgewicht * 1000; - $parcel->ParcelItems[] = $item; + if (!$this->app->erp->IsEU($json->country)) { + $parcel->CustomsInvoiceNr = $json->invoice_number; + $parcel->CustomsShipmentType = $json->shipment_type; + foreach ($json->positions as $pos) { + $item = new ParcelItem(); + $item->HsCode = $pos->zolltarifnummer ?? ''; + $item->Description = $pos->bezeichnung; + $item->Quantity = $pos->menge; + $item->OriginCountry = $pos->herkunftsland ?? ''; + $item->Price = $pos->zolleinzelwert; + $item->Weight = $pos->zolleinzelgewicht * 1000; + $parcel->ParcelItems[] = $item; + } } $parcel->Weight = floatval($json->weight) * 1000; $ret = new CreateShipmentResult(); @@ -154,6 +156,8 @@ class Versandart_sendcloud extends Versanddienstleister $p = new Product(); $p->Id = $item->Id; $p->Name = $item->Name; + $p->WeightMin = $item->MinWeight / 1000; + $p->WeightMax = $item->MaxWeight / 1000; $result[] = $p; } return $result;
{|Bezeichnung|}