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); $products = array_combine(array_column($products, 'Id'), $products);
$address['product'] = $products[0]->Id ?? ''; $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['form'] = $address;
$json['countries'] = $this->app->erp->GetSelectLaenderliste(); $json['countries'] = $countries;
$json['products'] = $products; $json['products'] = $products;
$json['customs_shipment_types'] = [ $json['customs_shipment_types'] = [
CustomsInfo::CUSTOMS_TYPE_GIFT => 'Geschenk', CustomsInfo::CUSTOMS_TYPE_GIFT => 'Geschenk',

View File

@ -73,7 +73,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Land|}:</td> <td>{|Land|}:</td>
<td> <td>
<select v-model="form.country" required> <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> </select>
</td> </td>
</tr> </tr>
@ -156,7 +156,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Produkt|}:</td> <td>{|Produkt|}:</td>
<td> <td>
<select v-model="form.product" required> <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> </select>
</td> </td>
</tr> </tr>
@ -170,29 +170,33 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<div class="col-md-12"> <div class="col-md-12">
<h2>{|Bestellung|}</h2> <h2>{|Bestellung|}</h2>
<table> <table>
<tr> <tbody>
<td>{|Bestellnummer|}:</td> <tr>
<td><input type="text" size="36" v-model="form.order_number"></td> <td>{|Bestellnummer|}:</td>
</tr> <td><input type="text" size="36" v-model="form.order_number"></td>
<tr> </tr>
<td>{|Rechnungsnummer|}:</td> <tr>
<td><input type="text" size="36" v-model="form.invoice_number"></td> <td>{|Versicherungssumme|}:</td>
</tr> <td><input type="text" size="10" v-model="form.total_insured_value"/></td>
<tr> </tr>
<td>{|Sendungsart|}:</td> </tbody>
<td> <tbody v-if="customsRequired()">
<select v-model="form.shipment_type"> <tr>
<option v-for="(value, key) in customs_shipment_types" :value="key">{{value}}</option> <td>{|Rechnungsnummer|}:</td>
</select> <td><input type="text" size="36" v-model="form.invoice_number" required="required"></td>
</td> </tr>
</tr> <tr>
<tr> <td>{|Sendungsart|}:</td>
<td>{|Versicherungssumme|}:</td> <td>
<td><input type="text" size="10" v-model="form.total_insured_value"/></td> <select v-model="form.shipment_type">
</tr> <option v-for="(value, key) in customs_shipment_types" :value="key">{{value}}</option>
</select>
</td>
</tr>
</tbody>
</table> </table>
</div> </div>
<div class="col-md-12"> <div class="col-md-12" v-if="customsRequired()">
<table> <table>
<tr> <tr>
<th>{|Bezeichnung|}</th> <th>{|Bezeichnung|}</th>
@ -269,10 +273,30 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
deletePosition: function (index) { deletePosition: function (index) {
this.form.positions.splice(index, 1); 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) { serviceAvailable: function (service) {
if (!this.products.hasOwnProperty(this.form.product)) if (!this.products.hasOwnProperty(this.form.product))
return false; return false;
return this.products[this.form.product].AvailableServices.indexOf(service) >= 0; 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->EMail = $json->email;
$parcel->Telephone = $json->phone; $parcel->Telephone = $json->phone;
$parcel->CountryState = $json->state; $parcel->CountryState = $json->state;
$parcel->CustomsInvoiceNr = $json->invoice_number;
$parcel->CustomsShipmentType = $json->shipment_type;
$parcel->TotalInsuredValue = $json->total_insured_value; $parcel->TotalInsuredValue = $json->total_insured_value;
$parcel->OrderNumber = $json->order_number; $parcel->OrderNumber = $json->order_number;
foreach ($json->positions as $pos) { if (!empty($json->shipment_type)) {
$item = new ParcelItem(); $parcel->CustomsInvoiceNr = $json->invoice_number;
$item->HsCode = $pos->zolltarifnummer; $parcel->CustomsShipmentType = $json->shipment_type;
$item->Description = $pos->bezeichnung; foreach ($json->positions as $pos) {
$item->Quantity = $pos->menge; $item = new ParcelItem();
$item->OriginCountry = $pos->herkunftsland; $item->HsCode = $pos->zolltarifnummer ?? '';
$item->Price = $pos->zolleinzelwert; $item->Description = $pos->bezeichnung;
$item->Weight = $pos->zolleinzelgewicht * 1000; $item->Quantity = $pos->menge;
$parcel->ParcelItems[] = $item; $item->OriginCountry = $pos->herkunftsland ?? '';
$item->Price = $pos->zolleinzelwert;
$item->Weight = $pos->zolleinzelgewicht * 1000;
$parcel->ParcelItems[] = $item;
}
} }
$parcel->Weight = floatval($json->weight) * 1000; $parcel->Weight = floatval($json->weight) * 1000;
$ret = new CreateShipmentResult(); $ret = new CreateShipmentResult();
@ -154,6 +156,8 @@ class Versandart_sendcloud extends Versanddienstleister
$p = new Product(); $p = new Product();
$p->Id = $item->Id; $p->Id = $item->Id;
$p->Name = $item->Name; $p->Name = $item->Name;
$p->WeightMin = $item->MinWeight / 1000;
$p->WeightMax = $item->MaxWeight / 1000;
$result[] = $p; $result[] = $p;
} }
return $result; return $result;