mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:17:30 -04:00
Workaround for wrong conversion
This commit is contained in:
parent
c16478bc06
commit
a4a23606ab
@ -14,6 +14,7 @@ namespace App\Jobs\Invoice;
|
|||||||
|
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use horstoeko\zugferd\ZugferdDocumentBuilder;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
@ -29,7 +30,7 @@ class CreateEInvoice implements ShouldQueue
|
|||||||
|
|
||||||
public $deleteWhenMissingModels = true;
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
public function __construct(private Invoice $invoice)
|
public function __construct(private Invoice $invoice, private bool $returnObject = false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ class CreateEInvoice implements ShouldQueue
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function handle(): string
|
public function handle(): string|ZugferdDocumentBuilder
|
||||||
{
|
{
|
||||||
/* Forget the singleton*/
|
/* Forget the singleton*/
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
@ -63,13 +64,13 @@ class CreateEInvoice implements ShouldQueue
|
|||||||
case "XInvoice-Extended":
|
case "XInvoice-Extended":
|
||||||
case "XInvoice-BasicWL":
|
case "XInvoice-BasicWL":
|
||||||
case "XInvoice-Basic":
|
case "XInvoice-Basic":
|
||||||
return (new ZugferdEInvoice($this->invoice))->run();
|
return (new ZugferdEInvoice($this->invoice, $this->returnObject))->run();
|
||||||
case "Facturae_3.2":
|
case "Facturae_3.2":
|
||||||
case "Facturae_3.2.1":
|
case "Facturae_3.2.1":
|
||||||
case "Facturae_3.2.2":
|
case "Facturae_3.2.2":
|
||||||
return (new FacturaEInvoice($this->invoice, str_replace("Facturae_", "", $e_invoice_type)))->run();
|
return (new FacturaEInvoice($this->invoice, str_replace("Facturae_", "", $e_invoice_type)))->run();
|
||||||
default:
|
default:
|
||||||
return (new ZugferdEInvoice($this->invoice))->run();
|
return (new ZugferdEInvoice($this->invoice, $this->returnObject))->run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,19 +47,12 @@ class MergeEInvoice implements ShouldQueue
|
|||||||
private function embedEInvoiceZuGFerD(): void
|
private function embedEInvoiceZuGFerD(): void
|
||||||
{
|
{
|
||||||
$filepath_pdf = $this->invoice->client->invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName();
|
$filepath_pdf = $this->invoice->client->invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName();
|
||||||
$e_invoice_path = $this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
|
|
||||||
$disk = config('filesystems.default');
|
$disk = config('filesystems.default');
|
||||||
$file = Storage::disk($disk)->exists($e_invoice_path);
|
$xrechnung = (new CreateEInvoice($this->invoice, true))->handle();
|
||||||
if (! $file){
|
|
||||||
(new CreateEInvoice($this->invoice))->handle();
|
|
||||||
}
|
|
||||||
$document = ZugferdDocumentReader::readAndGuessFromFile(Storage::disk($disk)->path($e_invoice_path));
|
|
||||||
|
|
||||||
|
|
||||||
if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) {
|
if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) {
|
||||||
Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()));
|
Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()));
|
||||||
}
|
}
|
||||||
$pdfBuilder = new ZugferdDocumentPdfBuilder($document, Storage::disk($disk)->path($filepath_pdf));
|
$pdfBuilder = new ZugferdDocumentPdfBuilder($xrechnung, Storage::disk($disk)->path($filepath_pdf));
|
||||||
$pdfBuilder->generateDocument();
|
$pdfBuilder->generateDocument();
|
||||||
$pdfBuilder->saveDocument(Storage::disk($disk)->path($filepath_pdf));
|
$pdfBuilder->saveDocument(Storage::disk($disk)->path($filepath_pdf));
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ use horstoeko\zugferd\codelists\ZugferdDutyTaxFeeCategories;
|
|||||||
class ZugferdEInvoice extends AbstractService
|
class ZugferdEInvoice extends AbstractService
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(public Invoice $invoice, private array $tax_map = [])
|
public function __construct(public Invoice $invoice, private readonly bool $returnObject = false, private array $tax_map = [])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run()
|
public function run(): string|ZugferdDocumentBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
$company = $this->invoice->company;
|
$company = $this->invoice->company;
|
||||||
@ -175,7 +175,9 @@ class ZugferdEInvoice extends AbstractService
|
|||||||
|
|
||||||
$xrechnung->writeFile(Storage::disk($disk)->path($client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml")));
|
$xrechnung->writeFile(Storage::disk($disk)->path($client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml")));
|
||||||
// The validity can be checked using https://portal3.gefeg.com/invoice/validation or https://e-rechnung.bayern.de/app/#/upload
|
// The validity can be checked using https://portal3.gefeg.com/invoice/validation or https://e-rechnung.bayern.de/app/#/upload
|
||||||
|
if ($this->returnObject){
|
||||||
|
return $xrechnung;
|
||||||
|
}
|
||||||
return $client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
|
return $client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user