1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

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 $task_id = '';
public $expense_id = '';
public static $casts = [
'task_id' => 'string',
'expense_id' => 'string',
'tax_id' => 'string',
'type_id' => 'string',
'quantity' => 'float',

View File

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

View File

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