Skip to content

API reference / Quittio \ Laravel \ Rendering

RenderedInvoice

final class in quittio/laravel · implements Illuminate\Contracts\Mail\Attachable, Illuminate\Contracts\Support\Responsable · uses DeliversFile

Quittio\Laravel\Rendering\RenderedInvoice · Source

Rendered invoice for Laravel: usable as mail attachment and as HTTP response, storable on any filesystem disk.

Methods#

MethodDescription
->__construct()
->as()The result for another format of the same run.
->cancel()Cancels this invoice: builds the cancellation with Quittio::cancellation() and renders it in the formats of this invoice. $lines cancels part of it, $history passes the earlier partial cancellations (see Quittio::cancellation()).
->contents()The main output: PDF, otherwise XML, HTML or JSON.
->core()The result of the core, e.g. for save() to a local path.
->data()The calculated invoice data of the run (totals, VAT breakdown, due date).
->download()
->filename()File name of the main output, from the configured pattern; $extension replaces the extension of the main output.
->format()Key of the format of this result, e.g. "zugferd".
->formats()
->hashes()
->hasPdf()Whether this format produced a PDF.
->hasXml()Whether this format produced XML (also the XML embedded in a PDF).
->html()The rendered template, as mPDF received it.
->json()The invoice as JSON (InvoiceData::toJson()).
->mimeType()MIME type of the main output (contents()).
->pdf()The PDF.
->profile()Profile of the XML; null for formats without XML.
->save()Stores the main output on a filesystem disk (default: quittio.storage.disk).
->stream()
->toMailAttachment()
->toResponse()
->validation()Validation result of this format; in the mode "warn" it may contain errors, empty in the mode "off".
->xml()The e-invoice XML, also the one embedded in the PDF.

__construct()#

public function __construct(RenderedInvoice $result)
ParameterTypeDescription
$resultRenderedInvoice

as()#

public function as(string $format): self

The result for another format of the same run.

ParameterTypeDescription
$formatstring
Returns
self
Throws
LogicException – when the format was not rendered in this run

cancel()#

public function cancel(
    string $number,
    ?string $reason = null,
    list<array{line: string, quantity?: BigDecimal|int|string, amount?: string}>|null $lines = null,
    Date|DateTimeInterface|string|null $issueDate = null,
    ?string $strategy = null,
    ?CancellationHistory $history = null,
): self

Cancels this invoice: builds the cancellation with Quittio::cancellation() and renders it in the formats of this invoice. $lines cancels part of it, $history passes the earlier partial cancellations (see Quittio::cancellation()).

ParameterTypeDescription
$numberstring
$reason?string = null
$lineslist<array{line: string, Quittio\Laravel\Rendering\quantity?: Brick\Math\BigDecimal|int|string, Quittio\Laravel\Rendering\amount?: string}>|null = null
$issueDateDate|DateTimeInterface|string|null = null
$strategy?string = null
$history?CancellationHistory = null
Returns
self

contents()#

public function contents(): string

The main output: PDF, otherwise XML, HTML or JSON.

Returns
string

core()#

public function core(): RenderedInvoice

The result of the core, e.g. for save() to a local path.

Returns
RenderedInvoice

data()#

public function data(): InvoiceData

The calculated invoice data of the run (totals, VAT breakdown, due date).

Returns
InvoiceData

download()#

public function download(?string $filename = null): Response
ParameterTypeDescription
$filename?string = null
Returns
Symfony\Component\HttpFoundation\Response

filename()#

public function filename(?string $extension = null): string

File name of the main output, from the configured pattern; $extension replaces the extension of the main output.

ParameterTypeDescription
$extension?string = null
Returns
string

format()#

public function format(): string

Key of the format of this result, e.g. "zugferd".

Returns
string

formats()#

public function formats(): list<string>
Returns
list<string>

hashes()#

public function hashes(): array<string, string>
Returns
array<string, string>

hasPdf()#

public function hasPdf(): bool

Whether this format produced a PDF.

Returns
bool

hasXml()#

public function hasXml(): bool

Whether this format produced XML (also the XML embedded in a PDF).

Returns
bool

html()#

public function html(): string

The rendered template, as mPDF received it.

Returns
string
Throws
LogicException – when the format produced no HTML

json()#

public function json(): string

The invoice as JSON (InvoiceData::toJson()).

Returns
string

mimeType()#

public function mimeType(): string

MIME type of the main output (contents()).

Returns
string

pdf()#

public function pdf(): string

The PDF.

Returns
string
Throws
LogicException – when the format produces no PDF (see hasPdf())

profile()#

public function profile(): ?Profile

Profile of the XML; null for formats without XML.

Returns
?Profile

save()#

public function save(?string $disk = null, ?string $path = null): string

Stores the main output on a filesystem disk (default: quittio.storage.disk).

ParameterTypeDescription
$disk?string = null
$path?string = null
Returns
string – the stored path
Throws
RuntimeException – when the disk does not store the file

stream()#

public function stream(?string $filename = null): Response
ParameterTypeDescription
$filename?string = null
Returns
Symfony\Component\HttpFoundation\Response

toMailAttachment()#

public function toMailAttachment(): Attachment
Returns
Illuminate\Mail\Attachment

toResponse()#

public function toResponse(Request $request): Response
ParameterTypeDescription
$requestIlluminate\Http\Request
Returns
Symfony\Component\HttpFoundation\Response

validation()#

public function validation(): ValidationResult

Validation result of this format; in the mode "warn" it may contain errors, empty in the mode "off".

Returns
ValidationResult

xml()#

public function xml(): string

The e-invoice XML, also the one embedded in the PDF.

Returns
string
Throws
LogicException – when the format produces no XML (see hasXml())

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.