From a8e313b5e9f799ba582b50d8c7c32db76ea58422 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 8 Aug 2024 14:16:35 +1000 Subject: [PATCH] Working on Peppol --- app/PaymentDrivers/BaseDriver.php | 2 + app/Services/EDocument/Standards/Peppol.php | 8 +- .../Einvoice/Storecove/StorecoveTest.php | 114 ++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 4c7dd2691013..26489ff7df13 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -400,6 +400,7 @@ class BaseDriver extends AbstractPaymentDriver return; $invoices = Invoice::query() + ->where('company_id', $this->company_gateway->company_id) ->whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id'))) ->whereJsonContains('line_items', ['type_id' => '3']) ->withTrashed(); @@ -407,6 +408,7 @@ class BaseDriver extends AbstractPaymentDriver if($invoices->count() == 0){ $invoice = Invoice::query() + ->where('company_id', $this->company_gateway->company_id) ->whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id'))) ->orderBy('id','desc') ->withTrashed() diff --git a/app/Services/EDocument/Standards/Peppol.php b/app/Services/EDocument/Standards/Peppol.php index 4e58949853b9..c01d6f7c23ce 100644 --- a/app/Services/EDocument/Standards/Peppol.php +++ b/app/Services/EDocument/Standards/Peppol.php @@ -1087,7 +1087,13 @@ class Peppol extends AbstractService return $this; } - + + /** + * FR + * @Pending - clarification on codes needed + * + * @return self + */ private function FR(): self { diff --git a/tests/Integration/Einvoice/Storecove/StorecoveTest.php b/tests/Integration/Einvoice/Storecove/StorecoveTest.php index 861f428994d3..fa7408d52291 100644 --- a/tests/Integration/Einvoice/Storecove/StorecoveTest.php +++ b/tests/Integration/Einvoice/Storecove/StorecoveTest.php @@ -503,6 +503,120 @@ $x = ' return $invoice; + } + + private function createFRData() + { + $this->routing_id = 293338; + + +$settings = CompanySettings::defaults(); +$settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png'; +$settings->website = 'www.invoiceninja.de'; + +$settings->address1 = '10 Rue de la Paix'; +$settings->address2 = 'Bâtiment A, Bureau 5'; +$settings->city = 'Paris'; +$settings->state = 'Île-de-France'; +$settings->postal_code = '75002'; +$settings->phone = '01 23456789'; +$settings->email = $this->faker->unique()->safeEmail(); +$settings->country_id = '250'; // France's ISO country code +$settings->vat_number = 'FR12345678901'; +$settings->id_number = '12345678900010'; + +$settings->use_credits_payment = 'always'; +$settings->timezone_id = '1'; // CET (Central European Time) +$settings->entity_send_time = 0; +$settings->e_invoice_type = 'PEPPOL'; +$settings->currency_id = '3'; + +$company = Company::factory()->create([ + 'account_id' => $this->account->id, + 'settings' => $settings, +]); + +$this->user->companies()->attach($company->id, [ + 'account_id' => $this->account->id, + 'is_owner' => true, + 'is_admin' => 1, + 'is_locked' => 0, + 'permissions' => '', + 'notifications' => CompanySettings::notificationAdminDefaults(), + 'settings' => null, +]); + +Client::unguard(); + +$c = +Client::create([ + 'company_id' => $company->id, + 'user_id' => $this->user->id, + 'name' => 'Beispiel Firma GmbH', + 'website' => 'https://www.beispiel-firma.de', + 'private_notes' => 'Dies sind private Notizen zum Testkunden.', + 'balance' => 0, + 'paid_to_date' => 0, + 'vat_number' => 'DE654321987', + 'id_number' => 'HRB 12345', // Typical format for German company registration numbers + 'custom_value1' => '2024-07-22 10:00:00', + 'custom_value2' => 'blau', + 'custom_value3' => 'musterwort', + 'custom_value4' => 'test@example.com', + 'address1' => 'Musterstraße 123', + 'address2' => '2. Etage, Büro 45', + 'city' => 'München', + 'state' => 'Bayern', + 'postal_code' => '80331', + 'country_id' => '276', // Germany + 'shipping_address1' => 'Musterstraße 123', + 'shipping_address2' => '2. Etage, Büro 45', + 'shipping_city' => 'München', + 'shipping_state' => 'Bayern', + 'shipping_postal_code' => '80331', + 'shipping_country_id' => '276', // Germany + 'settings' => ClientSettings::Defaults(), + 'client_hash' => \Illuminate\Support\Str::random(32), + 'routing_id' => '', +]); + + +$item = new InvoiceItem(); +$item->product_key = "Product Key"; +$item->notes = "Product Description"; +$item->cost = 10; +$item->quantity = 10; +$item->tax_rate1 = 19; +$item->tax_name1 = 'mwst'; + +$invoice = Invoice::factory()->create([ + 'company_id' => $company->id, + 'user_id' => $this->user->id, + 'client_id' => $c->id, + 'discount' => 0, + 'uses_inclusive_taxes' => false, + 'status_id' => 1, + 'tax_rate1' => 0, + 'tax_name1' => '', + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name2' => '', + 'tax_name3' => '', + 'line_items' => [$item], + 'number' => 'DE-'.rand(1000, 100000), + 'date' => now()->format('Y-m-d'), + 'due_date' => now()->addDays(14)->format('Y-m-d'), +]); + +$invoice = $invoice->calc()->getInvoice(); +$invoice->service()->markSent()->save(); + + +return $invoice; + + + + } private function createDEData()