|
@@ -137,12 +137,27 @@ $controller = new class($document_type, $document_number) {
|
|
|
|
|
|
|
|
if($location) {
|
|
if($location) {
|
|
|
$customer = $location->getCustomer();
|
|
$customer = $location->getCustomer();
|
|
|
- $address = $location->getAddress();
|
|
|
|
|
- $lines = array_merge([$location->name], $address->getLines());
|
|
|
|
|
- $address_string = implode("\n", $lines);
|
|
|
|
|
|
|
|
|
|
- $document->billing_address = $address_string;
|
|
|
|
|
- $document->delivery_address = $address_string;
|
|
|
|
|
|
|
+ $delivery_address = $location->getAddress();
|
|
|
|
|
+
|
|
|
|
|
+ $billing_entity = $location->getBillingEntity();
|
|
|
|
|
+ if($billing_entity) {
|
|
|
|
|
+ $billing_name = $billing_entity->name;
|
|
|
|
|
+ $billing_address = $billing_entity->getAddress();
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $billing_name = $customer->name;
|
|
|
|
|
+ $billing_address = $customer->getAddress();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $billing_lines = array_merge([$billing_name], $billing_address->getLines());
|
|
|
|
|
+ $billing_address_string = implode("\n", $billing_lines);
|
|
|
|
|
+
|
|
|
|
|
+ $delivery_lines = array_merge([$location->name], $delivery_address->getLines());
|
|
|
|
|
+ $delivery_address_string = implode("\n", $delivery_lines);
|
|
|
|
|
+
|
|
|
|
|
+ $document->billing_address = $billing_address_string;
|
|
|
|
|
+ $document->delivery_address = $delivery_address_string;
|
|
|
$document->vat_number = $customer->vat_number;
|
|
$document->vat_number = $customer->vat_number;
|
|
|
}
|
|
}
|
|
|
|
|
|