Skip to content

Commit

Permalink
Added option to return the invoices doc xml or just the specific invo…
Browse files Browse the repository at this point in the history
…ice xml in Invoice::toXml method.
  • Loading branch information
firebed committed Jun 12, 2024
1 parent 395a30c commit d601063
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit d601063

Please sign in to comment.