-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Implement PEPPOL e-invoicing with dynamic provider architecture #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nielsdrost7
merged 10 commits into
feature/implement-peppol
from
copilot/add-peppol-architecture-components
Oct 26, 2025
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0f05cf
Initial plan
Copilot 232802f
Add core PEPPOL database migrations, models, providers, and events
Copilot e857939
Add Jobs, Services, and enhanced configuration for PEPPOL lifecycle m…
Copilot 8acc617
Add audit listener, console commands, and comprehensive architecture …
Copilot e6a8303
Refactor PEPPOL to use enums, remove JSON columns, use key-value conf…
Copilot be13fbb
Implement dynamic provider discovery by scanning Providers directory
Copilot 704673a
Update Modules/Invoices/Models/CustomerPeppolValidationHistory.php
nielsdrost7 a36f032
📝 Add docstrings to `copilot/add-peppol-architecture-components` (#105)
coderabbitai[bot] 4d4c3e8
CodeRabbit Generated Unit Tests: Add PEPPOL PHPUnit test suite and te…
coderabbitai[bot] 81541f8
Merge branch 'feature/implement-peppol' into copilot/add-peppol-archi…
nielsdrost7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...Database/Migrations/2025_10_02_000007_add_peppol_validation_fields_to_relations_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::table('relations', function (Blueprint $table): void { | ||
| $table->string('peppol_scheme', 50)->nullable()->after('peppol_id') | ||
| ->comment('Peppol endpoint scheme (e.g., BE:CBE, DE:VAT)'); | ||
|
|
||
| $table->string('peppol_validation_status', 20)->nullable()->after('enable_e_invoicing') | ||
| ->comment('Quick lookup: valid, invalid, not_found, error, null'); | ||
|
|
||
| $table->text('peppol_validation_message')->nullable()->after('peppol_validation_status') | ||
| ->comment('Last validation result message'); | ||
|
|
||
| $table->timestamp('peppol_validated_at')->nullable()->after('peppol_validation_message') | ||
| ->comment('When was the Peppol ID last validated'); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::table('relations', function (Blueprint $table): void { | ||
| $table->dropColumn(['peppol_scheme', 'peppol_validation_status', 'peppol_validation_message', 'peppol_validated_at']); | ||
| }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Modules/Invoices/Console/Commands/PollPeppolStatusCommand.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| namespace Modules\Invoices\Console\Commands; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Modules\Invoices\Jobs\Peppol\PeppolStatusPoller; | ||
|
|
||
| /** | ||
| * Console command to poll Peppol transmission statuses | ||
| * | ||
| * Should be scheduled to run periodically (e.g., every 15 minutes) | ||
| * Add to schedule: $schedule->command('peppol:poll-status')->everyFifteenMinutes(); | ||
| */ | ||
| class PollPeppolStatusCommand extends Command | ||
| { | ||
| protected $signature = 'peppol:poll-status'; | ||
| protected $description = 'Poll Peppol provider for transmission status updates'; | ||
|
|
||
| public function handle(): int | ||
| { | ||
| $this->info('Starting Peppol status polling...'); | ||
|
|
||
| try { | ||
| PeppolStatusPoller::dispatch(); | ||
|
|
||
| $this->info('Peppol status polling job dispatched successfully.'); | ||
|
|
||
| return self::SUCCESS; | ||
| } catch (\Exception $e) { | ||
| $this->error('Failed to dispatch status polling job: ' . $e->getMessage()); | ||
|
|
||
| return self::FAILURE; | ||
| } | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
Modules/Invoices/Console/Commands/RetryFailedPeppolTransmissionsCommand.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| namespace Modules\Invoices\Console\Commands; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Modules\Invoices\Jobs\Peppol\RetryFailedTransmissions; | ||
|
|
||
| /** | ||
| * Console command to retry failed Peppol transmissions | ||
| * | ||
| * Should be scheduled to run frequently (e.g., every minute) | ||
| * Add to schedule: $schedule->command('peppol:retry-failed')->everyMinute(); | ||
| */ | ||
| class RetryFailedPeppolTransmissionsCommand extends Command | ||
| { | ||
| protected $signature = 'peppol:retry-failed'; | ||
| protected $description = 'Retry failed Peppol transmissions that are ready for retry'; | ||
|
|
||
| public function handle(): int | ||
| { | ||
| $this->info('Starting retry of failed Peppol transmissions...'); | ||
|
|
||
| try { | ||
| RetryFailedTransmissions::dispatch(); | ||
|
|
||
| $this->info('Retry job dispatched successfully.'); | ||
|
|
||
| return self::SUCCESS; | ||
| } catch (\Exception $e) { | ||
| $this->error('Failed to dispatch retry job: ' . $e->getMessage()); | ||
|
|
||
| return self::FAILURE; | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
Modules/Invoices/Console/Commands/TestPeppolIntegrationCommand.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| namespace Modules\Invoices\Console\Commands; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Modules\Invoices\Models\PeppolIntegration; | ||
| use Modules\Invoices\Peppol\Services\PeppolManagementService; | ||
|
|
||
| /** | ||
| * Console command to test a Peppol integration connection | ||
| */ | ||
| class TestPeppolIntegrationCommand extends Command | ||
| { | ||
| protected $signature = 'peppol:test-integration {integration_id}'; | ||
| protected $description = 'Test connection to a Peppol integration'; | ||
|
|
||
| public function handle(PeppolManagementService $service): int | ||
| { | ||
| $integrationId = $this->argument('integration_id'); | ||
|
|
||
| $integration = PeppolIntegration::find($integrationId); | ||
|
|
||
| if (!$integration) { | ||
| $this->error("Integration {$integrationId} not found."); | ||
| return self::FAILURE; | ||
| } | ||
|
|
||
| $this->info("Testing connection for integration: {$integration->provider_name}..."); | ||
|
|
||
| $result = $service->testConnection($integration); | ||
|
|
||
| if ($result['ok']) { | ||
| $this->info('✓ Connection test successful!'); | ||
| $this->line($result['message']); | ||
| return self::SUCCESS; | ||
| } else { | ||
| $this->error('✗ Connection test failed.'); | ||
| $this->error($result['message']); | ||
| return self::FAILURE; | ||
| } | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
Modules/Invoices/Database/Migrations/2025_10_02_000001_create_peppol_integrations_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::create('peppol_integrations', function (Blueprint $table): void { | ||
| $table->id(); | ||
| $table->unsignedBigInteger('company_id'); | ||
| $table->string('provider_name', 50)->comment('e.g., e_invoice_be, storecove'); | ||
| $table->text('encrypted_api_token')->nullable()->comment('Encrypted API credentials'); | ||
| $table->string('test_connection_status', 20)->default('untested')->comment('untested, success, failed'); | ||
| $table->text('test_connection_message')->nullable()->comment('Last test connection result message'); | ||
| $table->timestamp('test_connection_at')->nullable(); | ||
| $table->boolean('enabled')->default(false)->comment('Whether integration is active'); | ||
|
|
||
| $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade'); | ||
| $table->index(['company_id', 'enabled']); | ||
| $table->index('provider_name'); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::dropIfExists('peppol_integrations'); | ||
| } | ||
| }; |
26 changes: 26 additions & 0 deletions
26
...Invoices/Database/Migrations/2025_10_02_000002_create_peppol_integration_config_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::create('peppol_integration_config', function (Blueprint $table): void { | ||
| $table->id(); | ||
| $table->unsignedBigInteger('integration_id'); | ||
| $table->string('config_key', 100); | ||
| $table->text('config_value'); | ||
|
|
||
| $table->foreign('integration_id')->references('id')->on('peppol_integrations')->onDelete('cascade'); | ||
| $table->index(['integration_id', 'config_key']); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::dropIfExists('peppol_integration_config'); | ||
| } | ||
| }; |
46 changes: 46 additions & 0 deletions
46
Modules/Invoices/Database/Migrations/2025_10_02_000003_create_peppol_transmissions_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::create('peppol_transmissions', function (Blueprint $table): void { | ||
| $table->id(); | ||
| $table->unsignedBigInteger('invoice_id'); | ||
| $table->unsignedBigInteger('customer_id'); | ||
| $table->unsignedBigInteger('integration_id'); | ||
| $table->string('format', 50)->comment('Document format used (e.g., peppol_bis_3.0, ubl_2.1)'); | ||
| $table->string('status', 20)->default('pending')->comment('pending, queued, processing, sent, accepted, rejected, failed, retrying, dead'); | ||
| $table->unsignedInteger('attempts')->default(0); | ||
| $table->string('idempotency_key', 64)->unique()->comment('Hash to prevent duplicate transmissions'); | ||
| $table->string('external_id')->nullable()->comment('Provider transaction/document ID'); | ||
| $table->string('stored_xml_path')->nullable()->comment('Path to stored XML file'); | ||
| $table->string('stored_pdf_path')->nullable()->comment('Path to stored PDF file'); | ||
| $table->text('last_error')->nullable()->comment('Last error message if failed'); | ||
| $table->string('error_type', 20)->nullable()->comment('TRANSIENT, PERMANENT, UNKNOWN'); | ||
| $table->timestamp('sent_at')->nullable(); | ||
| $table->timestamp('acknowledged_at')->nullable(); | ||
| $table->timestamp('next_retry_at')->nullable(); | ||
| $table->timestamp('created_at')->nullable(); | ||
| $table->timestamp('updated_at')->nullable(); | ||
|
|
||
| $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); | ||
| $table->foreign('customer_id')->references('id')->on('relations')->onDelete('cascade'); | ||
| $table->foreign('integration_id')->references('id')->on('peppol_integrations')->onDelete('cascade'); | ||
|
|
||
| $table->index(['invoice_id', 'integration_id']); | ||
| $table->index('status'); | ||
| $table->index('external_id'); | ||
| $table->index('next_retry_at'); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::dropIfExists('peppol_transmissions'); | ||
| } | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.