From b6c23399c6f7acb5eb6d1e09594faa6922812933 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 30 Mar 2023 22:24:40 +0200 Subject: [PATCH] Versanddienstleister: display customs form only for non-EU countries, improve product/method selection --- www/lib/class.versanddienstleister.php | 5 +- .../versandarten/content/createshipment.tpl | 70 +++++++++++++------ www/lib/versandarten/sendcloud.php | 26 ++++--- 3 files changed, 66 insertions(+), 35 deletions(-) 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..4e4ebe03 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 (!empty($json->shipment_type)) { + $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|}