diff --git a/src/ZugferdDocument.php b/src/ZugferdDocument.php index 2e1aa56f..9f6f86fe 100644 --- a/src/ZugferdDocument.php +++ b/src/ZugferdDocument.php @@ -95,14 +95,13 @@ public function getInvoiceObject() } /** - * Sets the reference to the internal invoice object + * Create a new instance of the internal invoice object * - * @param \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwö\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice $invoiceObject * @return \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwö\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice */ - protected function setInvoiceObject($invoiceObject) + protected function createInvoiceObject() { - $this->invoiceObject = $invoiceObject; + $this->invoiceObject = $this->getObjectHelper()->getCrossIndustryInvoice(); return $this->invoiceObject; } diff --git a/src/ZugferdDocumentBuilder.php b/src/ZugferdDocumentBuilder.php index 23faee8a..1250fc14 100644 --- a/src/ZugferdDocumentBuilder.php +++ b/src/ZugferdDocumentBuilder.php @@ -97,7 +97,8 @@ public static function createNew(int $profileId): ZugferdDocumentBuilder */ public function initNewDocument(): ZugferdDocumentBuilder { - $this->setInvoiceObject($this->getObjectHelper()->getCrossIndustryInvoice()); + $this->createInvoiceObject(); + $this->headerTradeAgreement = $this->getInvoiceObject()->getSupplyChainTradeTransaction()->getApplicableHeaderTradeAgreement(); $this->headerTradeDelivery = $this->getInvoiceObject()->getSupplyChainTradeTransaction()->getApplicableHeaderTradeDelivery(); $this->headerTradeSettlement = $this->getInvoiceObject()->getSupplyChainTradeTransaction()->getApplicableHeaderTradeSettlement();