From 8fe73e9be97e5fde9c3ffbb2d05c18ba2875cc01 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sun, 10 Mar 2024 08:03:38 +0100 Subject: [PATCH] Refactor e-invoicing to allow more types for quotes, po, ... --- .../{Invoice => EInvoice}/CreateEInvoice.php | 7 ++++--- app/Livewire/PdfSlot.php | 2 +- .../Standards}/FacturaEInvoice.php | 2 +- .../Standards}/FatturaPA.php | 2 +- .../Standards}/RoEInvoice.php | 12 ++++++------ .../Standards}/ZugferdEInvoice.php | 2 +- app/Services/Invoice/InvoiceService.php | 18 +++++++++--------- app/Services/Pdf/PdfService.php | 2 +- tests/Feature/EInvoice/FacturaeTest.php | 5 ++--- tests/Feature/EInvoice/FatturaPATest.php | 4 ++-- tests/Unit/EInvoiceTest.php | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) rename app/Jobs/{Invoice => EInvoice}/CreateEInvoice.php (93%) rename app/Services/{Invoice/EInvoice => EInvoicing/Standards}/FacturaEInvoice.php (99%) rename app/Services/{Invoice/EInvoice => EInvoicing/Standards}/FatturaPA.php (99%) rename app/Services/{Invoice/EInvoice => EInvoicing/Standards}/RoEInvoice.php (99%) rename app/Services/{Invoice/EInvoice => EInvoicing/Standards}/ZugferdEInvoice.php (99%) diff --git a/app/Jobs/Invoice/CreateEInvoice.php b/app/Jobs/EInvoice/CreateEInvoice.php similarity index 93% rename from app/Jobs/Invoice/CreateEInvoice.php rename to app/Jobs/EInvoice/CreateEInvoice.php index 0ea7ae8a96d8..204bb9e036b2 100644 --- a/app/Jobs/Invoice/CreateEInvoice.php +++ b/app/Jobs/EInvoice/CreateEInvoice.php @@ -9,11 +9,11 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Jobs\Invoice; +namespace App\Jobs\EInvoice; use App\Models\Invoice; -use App\Services\Invoice\EInvoice\FacturaEInvoice; -use App\Services\Invoice\EInvoice\ZugferdEInvoice; +use App\Services\EInvoicing\Standards\FacturaEInvoice; +use App\Services\EInvoicing\Standards\ZugferdEInvoice; use App\Utils\Ninja; use horstoeko\zugferd\ZugferdDocumentBuilder; use Illuminate\Bus\Queueable; @@ -22,6 +22,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\App; +use function App\Jobs\Invoice\app; class CreateEInvoice implements ShouldQueue { diff --git a/app/Livewire/PdfSlot.php b/app/Livewire/PdfSlot.php index 1322d6a9664f..b81d5d9d3e4c 100644 --- a/app/Livewire/PdfSlot.php +++ b/app/Livewire/PdfSlot.php @@ -12,7 +12,7 @@ namespace App\Livewire; -use App\Jobs\Invoice\CreateEInvoice; +use App\Jobs\EInvoice\CreateEInvoice; use App\Libraries\MultiDB; use App\Models\CreditInvitation; use App\Models\InvoiceInvitation; diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/EInvoicing/Standards/FacturaEInvoice.php similarity index 99% rename from app/Services/Invoice/EInvoice/FacturaEInvoice.php rename to app/Services/EInvoicing/Standards/FacturaEInvoice.php index e4b7f28bd905..623fe724d172 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/EInvoicing/Standards/FacturaEInvoice.php @@ -9,7 +9,7 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Services\Invoice\EInvoice; +namespace App\Services\EInvoicing\Standards; use App\Models\Invoice; use App\Models\PaymentType; diff --git a/app/Services/Invoice/EInvoice/FatturaPA.php b/app/Services/EInvoicing/Standards/FatturaPA.php similarity index 99% rename from app/Services/Invoice/EInvoice/FatturaPA.php rename to app/Services/EInvoicing/Standards/FatturaPA.php index 2c448c7cfa1b..7b40e9c8b33f 100644 --- a/app/Services/Invoice/EInvoice/FatturaPA.php +++ b/app/Services/EInvoicing/Standards/FatturaPA.php @@ -9,7 +9,7 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Services\Invoice\EInvoice; +namespace App\Services\EInvoicing\Standards; use App\Models\Invoice; use App\Services\AbstractService; diff --git a/app/Services/Invoice/EInvoice/RoEInvoice.php b/app/Services/EInvoicing/Standards/RoEInvoice.php similarity index 99% rename from app/Services/Invoice/EInvoice/RoEInvoice.php rename to app/Services/EInvoicing/Standards/RoEInvoice.php index d01aae492022..4a8ce29969e9 100644 --- a/app/Services/Invoice/EInvoice/RoEInvoice.php +++ b/app/Services/EInvoicing/Standards/RoEInvoice.php @@ -9,28 +9,28 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Services\Invoice\EInvoice; +namespace App\Services\EInvoicing\Standards; use App\Models\Invoice; use App\Services\AbstractService; use CleverIt\UBL\Invoice\Address; +use CleverIt\UBL\Invoice\ClassifiedTaxCategory; use CleverIt\UBL\Invoice\Contact; use CleverIt\UBL\Invoice\Country; use CleverIt\UBL\Invoice\Generator; use CleverIt\UBL\Invoice\Invoice as UBLInvoice; use CleverIt\UBL\Invoice\InvoiceLine; use CleverIt\UBL\Invoice\Item; +use CleverIt\UBL\Invoice\LegalEntity; use CleverIt\UBL\Invoice\LegalMonetaryTotal; use CleverIt\UBL\Invoice\Party; +use CleverIt\UBL\Invoice\PayeeFinancialAccount; +use CleverIt\UBL\Invoice\PaymentMeans; +use CleverIt\UBL\Invoice\Price; use CleverIt\UBL\Invoice\TaxCategory; use CleverIt\UBL\Invoice\TaxScheme; use CleverIt\UBL\Invoice\TaxSubTotal; use CleverIt\UBL\Invoice\TaxTotal; -use CleverIt\UBL\Invoice\PaymentMeans; -use CleverIt\UBL\Invoice\PayeeFinancialAccount; -use CleverIt\UBL\Invoice\LegalEntity; -use CleverIt\UBL\Invoice\ClassifiedTaxCategory; -use CleverIt\UBL\Invoice\Price; class RoEInvoice extends AbstractService { diff --git a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php b/app/Services/EInvoicing/Standards/ZugferdEInvoice.php similarity index 99% rename from app/Services/Invoice/EInvoice/ZugferdEInvoice.php rename to app/Services/EInvoicing/Standards/ZugferdEInvoice.php index 59ab32605a58..c08cbe7d1fb7 100644 --- a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php +++ b/app/Services/EInvoicing/Standards/ZugferdEInvoice.php @@ -9,7 +9,7 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Services\Invoice\EInvoice; +namespace App\Services\EInvoicing\Standards; use App\Models\Invoice; use App\Models\Product; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index effe34daceba..5d13c90c473b 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -11,21 +11,21 @@ namespace App\Services\Invoice; -use App\Models\Task; -use App\Utils\Ninja; +use App\Events\Invoice\InvoiceWasArchived; +use App\Jobs\EInvoice\CreateEInvoice; +use App\Jobs\Entity\CreateRawPdf; +use App\Jobs\Inventory\AdjustProductInventory; +use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Models\CompanyGateway; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; use App\Models\Subscription; -use App\Models\CompanyGateway; -use Illuminate\Support\Carbon; +use App\Models\Task; +use App\Utils\Ninja; use App\Utils\Traits\MakesHash; -use App\Jobs\Entity\CreateRawPdf; -use App\Jobs\Invoice\CreateEInvoice; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; -use App\Events\Invoice\InvoiceWasArchived; -use App\Jobs\Inventory\AdjustProductInventory; -use App\Libraries\Currency\Conversion\CurrencyApi; class InvoiceService { diff --git a/app/Services/Pdf/PdfService.php b/app/Services/Pdf/PdfService.php index e0db7d406419..81162798c0e5 100644 --- a/app/Services/Pdf/PdfService.php +++ b/app/Services/Pdf/PdfService.php @@ -11,7 +11,7 @@ namespace App\Services\Pdf; -use App\Jobs\Invoice\CreateEInvoice; +use App\Jobs\EInvoice\CreateEInvoice; use App\Models\Company; use App\Models\CreditInvitation; use App\Models\Invoice; diff --git a/tests/Feature/EInvoice/FacturaeTest.php b/tests/Feature/EInvoice/FacturaeTest.php index 6909a79fc2a6..d070ab388e6d 100644 --- a/tests/Feature/EInvoice/FacturaeTest.php +++ b/tests/Feature/EInvoice/FacturaeTest.php @@ -11,7 +11,6 @@ namespace Tests\Feature\EInvoice; -use App\Services\Invoice\EInvoice\FacturaEInvoice; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Support\Facades\Storage; @@ -40,11 +39,11 @@ class FacturaeTest extends TestCase public function testInvoiceGeneration() { - $f = new FacturaEInvoice($this->invoice, "3.2.2"); + $f = new \App\Services\EInvoicing\Standards\FacturaEInvoice($this->invoice, "3.2.2"); $path = $f->run(); $this->assertNotNull($f->run()); - + // nlog($f->run()); // $this->assertTrue($this->validateInvoiceXML($path)); diff --git a/tests/Feature/EInvoice/FatturaPATest.php b/tests/Feature/EInvoice/FatturaPATest.php index dfe243f55823..f6c63d0653ec 100644 --- a/tests/Feature/EInvoice/FatturaPATest.php +++ b/tests/Feature/EInvoice/FatturaPATest.php @@ -11,7 +11,7 @@ namespace Tests\Feature\EInvoice; -use App\Services\Invoice\EInvoice\FatturaPA; +use App\Services\EInvoicing\Standards\FatturaPA; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Routing\Middleware\ThrottleRequests; use Tests\MockAccountData; @@ -42,7 +42,7 @@ class FatturaPATest extends TestCase $xml = $fat->run(); // nlog($xml); - + $this->assertnotNull($xml); } } diff --git a/tests/Unit/EInvoiceTest.php b/tests/Unit/EInvoiceTest.php index 7f0925d1cdff..4b8977dc50e2 100644 --- a/tests/Unit/EInvoiceTest.php +++ b/tests/Unit/EInvoiceTest.php @@ -9,8 +9,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +use App\Jobs\EInvoice\CreateEInvoice; use App\Jobs\Entity\CreateRawPdf; -use App\Jobs\Invoice\CreateEInvoice; use horstoeko\zugferd\ZugferdDocumentReader; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Routing\Middleware\ThrottleRequests;