Skip to content

Commit

Permalink
Added static constructor for Invoice model.
Browse files Browse the repository at this point in the history
  • Loading branch information
firebed committed Jun 21, 2024
1 parent 8a65ab6 commit a3f131f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Invoice extends Type
'otherTransportDetails' => TransportDetail::class,
];

public static function make(array $attributes = []): self
{
return new Invoice($attributes);
}

/**
* Συμπληρώνεται από την Υπηρεσία.
*
Expand Down Expand Up @@ -341,11 +346,11 @@ public function toXml(bool $asInvoicesDoc = false): string
{
$writer = new InvoicesDocWriter();
$fullXml = $writer->asXML(new InvoicesDoc($this));

if ($asInvoicesDoc) {
return $fullXml;
}

$doc = $writer->getDomDocument();
return $doc->saveXML($doc->getElementsByTagName('invoice')->item(0));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/SendInvoicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function test_it_sends_invoices_using_invoices_doc()

$invoicesDoc = new InvoicesDoc([new Invoice(), new Invoice()]);
$invoicesDoc->add(new Invoice());
$invoicesDoc->add(new Invoice());
$invoicesDoc->add(Invoice::make());
$invoicesDoc->add(new Invoice());

$sendInvoices = new SendInvoices();
Expand Down

0 comments on commit a3f131f

Please sign in to comment.