mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Merge pull request #73 from exciler/sendcloud
Versanddienstleiter improvement
This commit is contained in:
commit
7ee2bfae5b
@ -12,8 +12,9 @@ class ParcelCreation extends ParcelBase
|
|||||||
{
|
{
|
||||||
public ?int $SenderAddressId = null;
|
public ?int $SenderAddressId = null;
|
||||||
|
|
||||||
public function toApiRequest(): array {
|
public function toApiRequest(): array
|
||||||
return [
|
{
|
||||||
|
$data = [
|
||||||
'name' => $this->Name,
|
'name' => $this->Name,
|
||||||
'company_name' => $this->CompanyName,
|
'company_name' => $this->CompanyName,
|
||||||
'address' => $this->Address,
|
'address' => $this->Address,
|
||||||
@ -32,16 +33,19 @@ class ParcelCreation extends ParcelBase
|
|||||||
'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null),
|
'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null),
|
||||||
'country_state' => $this->CountryState,
|
'country_state' => $this->CountryState,
|
||||||
'sender_address' => $this->SenderAddressId,
|
'sender_address' => $this->SenderAddressId,
|
||||||
'customs_invoice_nr' => $this->CustomsInvoiceNr,
|
|
||||||
'customs_shipment_type' => $this->CustomsShipmentType,
|
|
||||||
'external_reference' => $this->ExternalReference,
|
'external_reference' => $this->ExternalReference,
|
||||||
'total_insured_value' => $this->TotalInsuredValue ?? 0,
|
'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,
|
'is_return' => $this->IsReturn,
|
||||||
'length' => $this->Length,
|
'length' => $this->Length,
|
||||||
'width' => $this->Width,
|
'width' => $this->Width,
|
||||||
'height' => $this->Height,
|
'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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -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',
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -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 (!$this->app->erp->IsEU($json->country)) {
|
||||||
$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;
|
||||||
|
Loading…
Reference in New Issue
Block a user