-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* @package Sales | ||
* @license http://www.gnu.org/licenses/agpl.html | ||
* @copyright Copyright (c) 2013-2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @copyright Copyright (c) 2013-2025 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @author Alexander Stintzing <[email protected]> | ||
* | ||
*/ | ||
|
@@ -321,6 +321,8 @@ public function testDeleteUsedBillingAddress() | |
'billing_address_id' => $customer['debitors'][0]['billing'][0]['id'], | ||
))); | ||
|
||
$this->assertInstanceOf(Sales_Model_Address::class, $contract->billing_address_id); | ||
|
||
// if the property is set to null, no handling of this dependent records must be done | ||
$customer['debitors'][0]['billing'] = NULL; | ||
$customer = $this->_json->saveCustomer($customer); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* @subpackage Controller | ||
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3 | ||
* @author Alexander Stintzing <[email protected]> | ||
* @copyright Copyright (c) 2013-2018 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @copyright Copyright (c) 2013-2025 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* | ||
*/ | ||
|
||
|
@@ -1512,10 +1512,18 @@ public function createXRechnungsAttachment(Sales_Model_Invoice $invoice): void | |
} | ||
try { | ||
$customer = $this->_getCustomerFromInvoiceRelations($invoice) ?? throw new Tinebase_Exception_SystemGeneric('invoice does not have a customer'); | ||
/** @var Sales_Model_Contract $contract */ | ||
$contract = $invoice->relations->find('type', 'CONTRACT')?->related_record; | ||
Tinebase_Record_Expander::expandRecord($customer); | ||
$debitor = $customer->{Sales_Model_Customer::FLD_DEBITORS}->getFirstRecord(); | ||
if ($contract = $invoice->relations->find('type', 'CONTRACT')?->related_record) { | ||
Tinebase_Record_Expander::expandRecord($contract); | ||
} | ||
$debitor = null; | ||
/** @var Sales_Model_Contract $contract */ | ||
if ($contract?->billing_address_id) { | ||
$debitor = $customer->{Sales_Model_Customer::FLD_DEBITORS}->find(fn($deb) => $deb->{Sales_Model_Debitor::FLD_BILLING}->getById($contract->getIdFromProperty('billing_address_id')), null); | ||
} | ||
if (null === $debitor) { | ||
$debitor = $customer->{Sales_Model_Customer::FLD_DEBITORS}->getFirstRecord(); | ||
} | ||
|
||
// type (invoice_type) => REVERSAL => storno gibt verknüpfung | ||
|
||
|
@@ -1530,7 +1538,8 @@ public function createXRechnungsAttachment(Sales_Model_Invoice $invoice): void | |
Sales_Model_Document_Invoice::FLD_CUSTOMER_ID => $customer, | ||
Sales_Model_Document_Invoice::FLD_CONTRACT_ID => $contract, | ||
Sales_Model_Document_Invoice::FLD_RECIPIENT_ID => new Sales_Model_Document_Address( | ||
$debitor->{Sales_Model_Debitor::FLD_BILLING}->getFirstRecord()->toArray(), true | ||
($contract?->billing_address_id ?: | ||
$debitor->{Sales_Model_Debitor::FLD_BILLING}->getFirstRecord())->toArray(), true | ||
), | ||
// TODO FIXME do we have a FLD_CONTACT_ID? | ||
Sales_Model_Document_Invoice::FLD_DOCUMENT_LANGUAGE => 'de', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* @package Sales | ||
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3 | ||
* @author Philipp Schüle <[email protected]> | ||
* @copyright Copyright (c) 2007-2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @copyright Copyright (c) 2007-2025 Metaways Infosystems GmbH (http://www.metaways.de) | ||
*/ | ||
|
||
/** | ||
|
@@ -99,6 +99,7 @@ class Sales_Model_Contract extends Tinebase_Record_Abstract | |
|
||
self::JSON_EXPANDER => [ | ||
Tinebase_Record_Expander::EXPANDER_PROPERTIES => [ | ||
'billing_address_id' => [], | ||
'products' => [ | ||
Tinebase_Record_Expander::EXPANDER_PROPERTIES => [ | ||
'product_id' => [ | ||
|