Minor fixes for return types for e-invoices

This commit is contained in:
David Bomba 2023-08-16 15:38:08 +10:00
parent 035300bfcf
commit 33dd437d96
4 changed files with 29 additions and 19 deletions

View File

@ -61,8 +61,13 @@ class InvoiceItem
public $tax_id = ''; public $tax_id = '';
public $task_id = '';
public $expense_id = '';
public static $casts = [ public static $casts = [
'task_id' => 'string',
'expense_id' => 'string',
'tax_id' => 'string', 'tax_id' => 'string',
'type_id' => 'string', 'type_id' => 'string',
'quantity' => 'float', 'quantity' => 'float',

View File

@ -38,7 +38,7 @@ class CreateEInvoice implements ShouldQueue
* Execute the job. * Execute the job.
* *
* *
* @return string * @return string|ZugferdDocumentBuilder
*/ */
public function handle(): string|ZugferdDocumentBuilder public function handle(): string|ZugferdDocumentBuilder
{ {

View File

@ -46,23 +46,25 @@ class MergeEInvoice implements ShouldQueue
*/ */
private function embedEInvoiceZuGFerD(): void private function embedEInvoiceZuGFerD(): void
{ {
$filepath_pdf = !empty($this->pdf_path) ? $this->pdf_path : $this->invoice->service()->getInvoicePdf(); try {
$disk = config('filesystems.default'); $filepath_pdf = !empty($this->pdf_path) ? $this->pdf_path : $this->invoice->service()->getInvoicePdf();
$e_rechnung = (new CreateEInvoice($this->invoice, true))->handle(); $disk = config('filesystems.default');
if (!empty($this->pdf_path)){ $e_rechnung = (new CreateEInvoice($this->invoice, true))->handle();
$realpath_pdf = $filepath_pdf; if (!empty($this->pdf_path)) {
} $realpath_pdf = $filepath_pdf;
else { } else {
$realpath_pdf = Storage::disk($disk)->path($filepath_pdf); $realpath_pdf = Storage::disk($disk)->path($filepath_pdf);
} }
if (file_exists($realpath_pdf)){ if (file_exists($realpath_pdf)) {
$pdfBuilder = new ZugferdDocumentPdfBuilder($e_rechnung, $realpath_pdf); $pdfBuilder = new ZugferdDocumentPdfBuilder($e_rechnung, $realpath_pdf);
$pdfBuilder->generateDocument(); $pdfBuilder->generateDocument();
$pdfBuilder->saveDocument($realpath_pdf); $pdfBuilder->saveDocument($realpath_pdf);
} } else {
else{ nlog("E_Invoice Merge failed - file to merge not found");
nlog("E_Invoice Merge failed - file to merge not found"); }
}
} catch (\Exception $e) {
nlog("E_Invoice Merge failed - " . $e->getMessage());
}
} }
} }

View File

@ -178,7 +178,10 @@ class ZugferdEInvoice extends AbstractService
if ($this->returnObject){ if ($this->returnObject){
return $xrechnung; return $xrechnung;
} }
return $client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
throw new \Exception("Invalid e invoice object");
// return $client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
} }
private function getTaxType($name): string private function getTaxType($name): string