diff --git a/app/Services/EDocument/Gateway/Storecove/Models/AccountingCustomerParty.php b/app/Services/EDocument/Gateway/Storecove/Models/AccountingCustomerParty.php index 3be5b4e545..f87865b66d 100644 --- a/app/Services/EDocument/Gateway/Storecove/Models/AccountingCustomerParty.php +++ b/app/Services/EDocument/Gateway/Storecove/Models/AccountingCustomerParty.php @@ -50,4 +50,10 @@ class AccountingCustomerParty $this->public_identifiers = $public_identifiers; return $this; } + + public function addPublicIdentifiers($public_identifier): self + { + $this->public_identifiers[] = $public_identifier; + return $this; + } } diff --git a/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php b/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php index 390062af51..e3ef42e023 100644 --- a/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php +++ b/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php @@ -208,7 +208,20 @@ nlog($peppolInvoice); $this->storecove_invoice->setAllowanceCharges($allowances); $this->storecove_invoice->setTaxSystem('tax_line_percentages'); - //set additional identifier if required (ie de => FR with FR vat) + + //resolve and set the public identifier for the customer + + $accounting_customer_party = $this->storecove_invoice->getAccountingCustomerParty(); + + if(strlen($this->ninja_invoice->client->vat_number) > 2) + { + $id = $this->ninja_invoice->client->vat_number; + $scheme = $this->storecove->router->resolveTaxScheme($this->ninja_invoice->client->country->iso_3166_2, $this->ninja_invoice->client->classification ?? 'individual'); + $pi = new \App\Services\EDocument\Gateway\Storecove\Models\PublicIdentifiers($scheme, $id); + $accounting_customer_party->addPublicIdentifiers($pi); + $this->storecove_invoice->setAccountingCustomerParty($accounting_customer_party); + } + return $this; }