Versanddienstleister: display customs form only for non-EU countries, improve product/method selection

This commit is contained in:
Andreas Palm 2023-03-30 22:24:40 +02:00
parent c361a82583
commit b6c23399c6
3 changed files with 66 additions and 35 deletions

View File

@ -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',

View File

@ -73,7 +73,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Land|}:</td>
<td>
<select v-model="form.country" required>
<option v-for="(value, key) in countries" :value="key">{{value}}</option>
<option v-for="(value, key) in countries" :value="key">{{value.name}}</option>
</select>
</td>
</tr>
@ -156,7 +156,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Produkt|}:</td>
<td>
<select v-model="form.product" required>
<option v-for="prod in products" :value="prod.Id">{{prod.Name}}</option>
<option v-for="prod in products" :value="prod.Id" v-if="productAvailable(prod)">{{prod.Name}}</option>
</select>
</td>
</tr>
@ -170,29 +170,33 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<div class="col-md-12">
<h2>{|Bestellung|}</h2>
<table>
<tr>
<td>{|Bestellnummer|}:</td>
<td><input type="text" size="36" v-model="form.order_number"></td>
</tr>
<tr>
<td>{|Rechnungsnummer|}:</td>
<td><input type="text" size="36" v-model="form.invoice_number"></td>
</tr>
<tr>
<td>{|Sendungsart|}:</td>
<td>
<select v-model="form.shipment_type">
<option v-for="(value, key) in customs_shipment_types" :value="key">{{value}}</option>
</select>
</td>
</tr>
<tr>
<td>{|Versicherungssumme|}:</td>
<td><input type="text" size="10" v-model="form.total_insured_value"/></td>
</tr>
<tbody>
<tr>
<td>{|Bestellnummer|}:</td>
<td><input type="text" size="36" v-model="form.order_number"></td>
</tr>
<tr>
<td>{|Versicherungssumme|}:</td>
<td><input type="text" size="10" v-model="form.total_insured_value"/></td>
</tr>
</tbody>
<tbody v-if="customsRequired()">
<tr>
<td>{|Rechnungsnummer|}:</td>
<td><input type="text" size="36" v-model="form.invoice_number" required="required"></td>
</tr>
<tr>
<td>{|Sendungsart|}:</td>
<td>
<select v-model="form.shipment_type">
<option v-for="(value, key) in customs_shipment_types" :value="key">{{value}}</option>
</select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-12">
<div class="col-md-12" v-if="customsRequired()">
<table>
<tr>
<th>{|Bezeichnung|}</th>
@ -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;
}
}
}
})

View File

@ -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;