From 05019e7575d19a3b7c30e79f8165b5c8555a414a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Jul 2024 07:31:56 +1000 Subject: [PATCH] Adjustments for balance check in auto bill --- .../Invoice/InvoiceItemSumInclusive.php | 2 +- .../Stripe/Jobs/PaymentIntentWebhook.php | 9 +++++++ .../EDocument/Gateway/Storecove/Storecove.php | 14 ++++------- app/Services/Invoice/AutoBillInvoice.php | 2 +- .../Einvoice/Storecove/StorecoveTest.php | 24 +++++++++++++++++-- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index eacb13afb9e5..da4c3e1f3aa4 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -411,7 +411,7 @@ class InvoiceItemSumInclusive $this->rule = new $class(); - if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) { + if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2 ?? false)) { return $this; } diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index 367a99c24206..1cde9a8fffd2 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -313,4 +313,13 @@ class PaymentIntentWebhook implements ShouldQueue $client->company, ); } + + public function failed($exception = null) + { + if ($exception) { + nlog($exception->getMessage()); + } + + config(['queue.failed.driver' => null]); + } } diff --git a/app/Services/EDocument/Gateway/Storecove/Storecove.php b/app/Services/EDocument/Gateway/Storecove/Storecove.php index 24d677543c58..fa84fbd615bf 100644 --- a/app/Services/EDocument/Gateway/Storecove/Storecove.php +++ b/app/Services/EDocument/Gateway/Storecove/Storecove.php @@ -32,7 +32,7 @@ class Storecove { "network" => "peppol", "metaScheme" => "iso6523-actorid-upis", "scheme" => "de:lwid", - "identifier" => "10101010-STO-10" + "identifier" => "DE:VAT" ]; private array $dbn_discovery = [ @@ -102,18 +102,14 @@ class Storecove { $payload = [ "legalEntityId"=> 290868, - "idempotencyGuid"=> "61b37456-5f9e-4d56-b63b-3b1a23fa5c73", + "idempotencyGuid"=> \Illuminate\Support\Str::uuid(), "routing"=> [ "eIdentifiers" => [ [ - "scheme"=> "DE:LWID", - "id"=> "10101010-STO-10" + "scheme" => "DE:VAT", + "id"=> "DE:VAT" ], - ], - "emails"=> [ - "david@invoiceninja.com" - ], - "eIdentifiers"=> [] + ] ], "document"=> [ 'documentType' => 'invoice', diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 5e6844fffaad..a9c9f415396d 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -62,7 +62,7 @@ class AutoBillInvoice extends AbstractService $this->invoice = $this->invoice->service()->markSent()->save(); /* Mark the invoice as paid if there is no balance */ - if ((int) $this->invoice->balance == 0) { + if (floatval($this->invoice->balance) == 0) { return $this->invoice->service()->markPaid()->save(); } diff --git a/tests/Integration/Einvoice/Storecove/StorecoveTest.php b/tests/Integration/Einvoice/Storecove/StorecoveTest.php index 9014662aba8e..d78c1ed5a4a6 100644 --- a/tests/Integration/Einvoice/Storecove/StorecoveTest.php +++ b/tests/Integration/Einvoice/Storecove/StorecoveTest.php @@ -31,7 +31,7 @@ class StorecoveTest extends TestCase $this->markTestSkipped("do not run in CI"); } - public function teseateLegalEntity() + public function testCreateLegalEntity() { $data = [ @@ -47,6 +47,10 @@ class StorecoveTest extends TestCase 'tax_registered' => true, 'tenant_id' => $this->company->company_key, 'zip' => $this->company->settings->postal_code, + 'peppol_identifiers' => [ + 'scheme' => 'DE:VAT', + 'id' => 'DE:VAT' + ], ]; $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); @@ -56,6 +60,22 @@ class StorecoveTest extends TestCase } + // public function testUpdateLegalEntity() + // { + // $data = [ + // 'peppol_identifiers' => [ + // 'scheme' => 'DE:VAT', + // 'id' => 'DE:VAT' + // ], + // ]; + + // $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); + // $r = $sc->updateLegalEntity(290868, $data); + + // $this->assertIsArray($r); + // nlog($r); + + // } public function testGetLegalEntity() { @@ -66,7 +86,7 @@ class StorecoveTest extends TestCase $this->assertIsArray($r); - // nlog($r); + nlog($r); }