diff --git a/app/Services/EDocument/Gateway/Storecove/Storecove.php b/app/Services/EDocument/Gateway/Storecove/Storecove.php
index 0dce32741c68..24d677543c58 100644
--- a/app/Services/EDocument/Gateway/Storecove/Storecove.php
+++ b/app/Services/EDocument/Gateway/Storecove/Storecove.php
@@ -9,12 +9,11 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
-namespace App\Services\EDocument\Gateway;
+namespace App\Services\EDocument\Gateway\Storecove;
use App\Models\Company;
use Illuminate\Support\Facades\Http;
-
enum HttpVerb: string
{
case POST = 'post';
@@ -26,7 +25,7 @@ enum HttpVerb: string
class Storecove {
- private string $base_url = 'https://api.storecove.com/';
+ private string $base_url = 'https://api.storecove.com/api/v2/';
private array $peppol_discovery = [
"documentTypes" => ["invoice"],
@@ -102,16 +101,35 @@ class Storecove {
{
$payload = [
- 'documentType' => 'invoice',
- 'rawDocumentData' => base64_encode($document),
- 'parse' => true,
- 'parseStrategy', 'ubl'
+ "legalEntityId"=> 290868,
+ "idempotencyGuid"=> "61b37456-5f9e-4d56-b63b-3b1a23fa5c73",
+ "routing"=> [
+ "eIdentifiers" => [
+ [
+ "scheme"=> "DE:LWID",
+ "id"=> "10101010-STO-10"
+ ],
+ ],
+ "emails"=> [
+ "david@invoiceninja.com"
+ ],
+ "eIdentifiers"=> []
+ ],
+ "document"=> [
+ 'documentType' => 'invoice',
+ 'rawDocumentData' => ['document' => base64_encode($document)],
+ 'parse' => true,
+ 'parseStrategy', 'ubl'
+ ],
];
- $uri = "api/v2/document_submissions";
+ $uri = "document_submissions";
$r = $this->httpClient($uri, (HttpVerb::POST)->value, $payload, $this->getHeaders());
+ nlog($r->body());
+ nlog($r->json());
+
if($r->successful())
return $r->json()['guid'];
@@ -122,7 +140,7 @@ class Storecove {
//document submission sending evidence
public function getSendingEvidence(string $guid)
{
- $uri = "api/v2/document_submissions/{$guid}";
+ $uri = "document_submissions/{$guid}";
$r = $this->httpClient($uri, (HttpVerb::GET)->value, [], $this->getHeaders());
}
@@ -214,6 +232,21 @@ class Storecove {
}
+ public function getLegalEntity($id)
+ {
+
+ $uri = "legal_entities/{$id}";
+
+ $r = $this->httpClient($uri, (HttpVerb::GET)->value, []);
+
+ if($r->successful()) {
+ return $r->json();
+ }
+
+ return $r;
+
+ }
+
public function updateLegalEntity($id, array $data)
{
@@ -242,7 +275,7 @@ class Storecove {
private function httpClient(string $uri, string $verb, array $data, ?array $headers = [])
{
-
+nlog("{$this->base_url}{$uri}");
$r = Http::withToken(config('ninja.storecove_api_key'))
->withHeaders($this->getHeaders($headers))
->{$verb}("{$this->base_url}{$uri}", $data);
diff --git a/app/Services/EDocument/Standards/Peppol.php b/app/Services/EDocument/Standards/Peppol.php
index fca7ac0ecedb..572f69212838 100644
--- a/app/Services/EDocument/Standards/Peppol.php
+++ b/app/Services/EDocument/Standards/Peppol.php
@@ -15,6 +15,7 @@ use App\Models\Invoice;
use App\Services\AbstractService;
use App\Helpers\Invoice\InvoiceSum;
use App\Helpers\Invoice\InvoiceSumInclusive;
+use InvoiceNinja\EInvoice\EInvoice;
use InvoiceNinja\EInvoice\Models\Peppol\ItemType\Item;
use InvoiceNinja\EInvoice\Models\Peppol\PartyType\Party;
use InvoiceNinja\EInvoice\Models\Peppol\PriceType\Price;
@@ -78,6 +79,12 @@ class Peppol extends AbstractService
}
+ public function toXml(): string
+ {
+ $e = new EInvoice();
+ return $e->encode($this->p_invoice, 'xml');
+ }
+
public function run()
{
$this->p_invoice->ID = $this->invoice->number;
diff --git a/tests/Integration/Einvoice/Storecove/StorecoveTest.php b/tests/Integration/Einvoice/Storecove/StorecoveTest.php
new file mode 100644
index 000000000000..9014662aba8e
--- /dev/null
+++ b/tests/Integration/Einvoice/Storecove/StorecoveTest.php
@@ -0,0 +1,200 @@
+makeTestData();
+
+ if (config('ninja.testvars.travis') !== false || !config('ninja.storecove_api_key'))
+ $this->markTestSkipped("do not run in CI");
+ }
+
+ public function teseateLegalEntity()
+ {
+
+ $data = [
+ 'acts_as_receiver' => true,
+ 'acts_as_sender' => true,
+ 'advertisements' => ['invoice'],
+ 'city' => $this->company->settings->city,
+ 'country' => 'DE',
+ 'county' => $this->company->settings->state,
+ 'line1' => $this->company->settings->address1,
+ 'line2' => $this->company->settings->address2,
+ 'party_name' => $this->company->present()->name(),
+ 'tax_registered' => true,
+ 'tenant_id' => $this->company->company_key,
+ 'zip' => $this->company->settings->postal_code,
+ ];
+
+ $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove();
+ $r = $sc->createLegalEntity($data, $this->company);
+
+ $this->assertIsArray($r);
+
+ }
+
+
+ public function testGetLegalEntity()
+ {
+
+
+ $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove();
+ $r = $sc->getLegalEntity(290868);
+
+ $this->assertIsArray($r);
+
+ // nlog($r);
+
+ }
+
+ public function testSendDocument()
+ {
+
+ $x = '
+ 0061
+ 2024-07-15
+ 380
+
+
+
+ Eladio Ullrich I
+
+
+ Jasper Brook
+ Kodychester
+ 73445-5131
+ South Dakota
+
+ AT
+
+
+
+ Jasper Brook
+ Kodychester
+ 73445-5131
+ South Dakota
+
+ AT
+
+
+
+ small@example.com
+
+
+
+
+
+
+ Beispiel GmbH
+
+
+ 45 Hauptstraße
+ Berlin
+ 10115
+ Berlin
+
+ DE
+
+
+
+ 45 Hauptstraße
+ Berlin
+ 10115
+ Berlin
+
+ DE
+
+
+
+ TTKGjKW9Rv00LEr@example.com
+
+
+
+
+
+ 215
+ 215
+ 215.00
+ 215.00
+
+
+ 1
+ 1
+ 10
+
+ 0.5
+
+ 10
+ 0.5
+
+ C62
+ 20
+
+ USt
+
+
+
+
+
+ The Pro Plan NO MORE
+ ee
+
+
+ 10
+
+
+
+ 2
+ 1
+ 14
+
+ The Enterprise Plan
+ eee
+
+
+ 14
+
+
+
+ 3
+ 1
+ 191
+
+ Soluta provident.
+ k
+
+
+ 191
+
+ ';
+
+
+ $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove();
+ $sc->sendDocument($x);
+
+ }
+
+}