Make shipping adress optional

This commit is contained in:
Lars Kusch 2023-04-24 07:50:45 +02:00
parent b51eb5e23c
commit 450670f841

View File

@ -34,35 +34,16 @@ class ZugferdEInvoice extends AbstractService
$client = $this->invoice->client;
$profile = $client->getSetting('e_invoice_type');
switch ($profile) {
case "EN16931":
$profile = ZugferdProfiles::PROFILE_EN16931;
break;
case "XInvoice_2_2":
$profile = ZugferdProfiles::PROFILE_XRECHNUNG_2_2;
break;
case "XInvoice_2_1":
$profile = ZugferdProfiles::PROFILE_XRECHNUNG_2_1;
break;
case "XInvoice_2_0":
$profile = ZugferdProfiles::PROFILE_XRECHNUNG_2;
break;
case "XInvoice_1_0":
$profile = ZugferdProfiles::PROFILE_XRECHNUNG;
break;
case "XInvoice-Extended":
$profile = ZugferdProfiles::PROFILE_EXTENDED;
break;
case "XInvoice-BasicWL":
$profile = ZugferdProfiles::PROFILE_BASICWL;
break;
case "XInvoice-Basic":
$profile = ZugferdProfiles::PROFILE_BASIC;
break;
default:
$profile = ZugferdProfiles::PROFILE_EN16931;
break;
}
$profile = match ($profile) {
"XInvoice_2_2" => ZugferdProfiles::PROFILE_XRECHNUNG_2_2,
"XInvoice_2_1" => ZugferdProfiles::PROFILE_XRECHNUNG_2_1,
"XInvoice_2_0" => ZugferdProfiles::PROFILE_XRECHNUNG_2,
"XInvoice_1_0" => ZugferdProfiles::PROFILE_XRECHNUNG,
"XInvoice-Extended" => ZugferdProfiles::PROFILE_EXTENDED,
"XInvoice-BasicWL" => ZugferdProfiles::PROFILE_BASICWL,
"XInvoice-Basic" => ZugferdProfiles::PROFILE_BASIC,
default => ZugferdProfiles::PROFILE_EN16931,
};
$xrechnung = ZugferdDocumentBuilder::CreateNew($profile);
@ -76,7 +57,6 @@ class ZugferdEInvoice extends AbstractService
->setDocumentBuyer($client->name, $client->number)
->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->iso_3166_2)
->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email)
->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state)
->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($this->invoice->date)->diff(date_create($this->invoice->due_date))->format("%d"), 'paydate' => $this->invoice->due_date]));
if (!empty($this->invoice->public_notes)) {
@ -92,6 +72,9 @@ class ZugferdEInvoice extends AbstractService
} else {
$xrechnung->setDocumentBuyerReference($client->routing_id);
}
if (!empty($client->shipping_address1)){
$xrechnung->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state);
}
$xrechnung->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment"));