diff --git a/src/Models/Invoice.php b/src/Models/Invoice.php index c0e261b..8ce3b4a 100644 --- a/src/Models/Invoice.php +++ b/src/Models/Invoice.php @@ -335,10 +335,15 @@ public function set($key, $value): static return parent::set($key, $value); } - public function toXml(): string + public function toXml(bool $asInvoicesDoc = false): string { $writer = new InvoicesDocWriter(); - $writer->asXML(new InvoicesDoc($this)); + $fullXml = $writer->asXML(new InvoicesDoc($this)); + + if ($asInvoicesDoc) { + return $fullXml; + } + $doc = $writer->getDomDocument(); return $doc->saveXML($doc->getElementsByTagName('invoice')->item(0)); }