Updates for PEPPOL invoices

This commit is contained in:
David Bomba
2026-01-14 12:32:22 +11:00
parent faa67f7cc0
commit 7351494447
5 changed files with 16 additions and 12 deletions

View File

@@ -112,11 +112,11 @@ class SwissQrGenerator
// Add payment reference
// This is what you will need to identify incoming payments.
if (stripos($this->invoice->number, "Live") === 0) {
if (stripos($this->invoice->number ?? '', "Live") === 0) {
// we're currently in preview status. Let's give a dummy reference for now
$invoice_number = "123456789";
} else {
$tempInvoiceNumber = $this->invoice->number;
$tempInvoiceNumber = $this->invoice->number ?? '';
$tempInvoiceNumber = preg_replace('/[^A-Za-z0-9]/', '', $tempInvoiceNumber);
// $tempInvoiceNumber = substr($tempInvoiceNumber, 1);

View File

@@ -279,7 +279,7 @@ class BaseModel extends Model
public function numberFormatter()
{
$number = strlen($this->number) >= 1 ? $this->translate_entity() . "_" . $this->number : class_basename($this) . "_" . Str::random(5);
$number = strlen($this->number ?? '') >= 1 ? $this->translate_entity() . "_" . $this->number : class_basename($this) . "_" . Str::random(5);
$formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $number);

View File

@@ -38,7 +38,7 @@ use App\Utils\Number;
* App\Models\Invoice
*
* @property int $id
* @property object|null $e_invoice
* @property object|array|null $e_invoice
* @property int $client_id
* @property int $user_id
* @property int|null $location_id

View File

@@ -65,7 +65,7 @@ class Peppol extends AbstractService
*
*/
private ?string $override_vat_number;
private string $override_vat_number = '';
/** @var array $InvoiceTypeCodes */
private array $InvoiceTypeCodes = [
@@ -657,7 +657,8 @@ class Peppol extends AbstractService
$tax_type = 'S';
break;
case Product::PRODUCT_TYPE_REDUCED_TAX:
$tax_type = 'AA';
// $tax_type = 'AA';
$tax_type = 'S'; //2026-01-14 - using AA breaks PEPPOL VALIDATION!!
break;
case Product::PRODUCT_TYPE_EXEMPT:
$tax_type = 'E';
@@ -759,10 +760,12 @@ class Peppol extends AbstractService
$this->globalTaxCategories = [$taxCategory];
if ($this->tax_category_id == 'O' && isset($this->p_invoice->AccountingSupplierParty->Party->PartyTaxScheme)) {
nlog("unset 1");
unset($this->p_invoice->AccountingSupplierParty->Party->PartyTaxScheme);
}
if ($this->tax_category_id == 'O' && isset($this->p_invoice->AccountingCustomerParty->Party->PartyTaxScheme)) {
nlog("unset 2");
unset($this->p_invoice->AccountingCustomerParty->Party->PartyTaxScheme);
}
@@ -1032,18 +1035,18 @@ class Peppol extends AbstractService
$party->PartyName[] = $party_name;
if (strlen($this->company->settings->vat_number ?? '') > 1) {
$pi = new PartyIdentification();
$vatID = new ID();
$vatID->schemeID = $this->resolveScheme();
$vatID->value = $this->override_vat_number ?? preg_replace("/[^a-zA-Z0-9]/", "", $this->invoice->company->settings->vat_number); //todo if we are cross border - switch to the supplier local vat number
$vatID->value = strlen($this->override_vat_number ?? '') > 1 ? $this->override_vat_number : preg_replace("/[^a-zA-Z0-9]/", "", $this->invoice->company->settings->vat_number); //todo if we are cross border - switch to the supplier local vat number
$pi->ID = $vatID;
$party->PartyIdentification[] = $pi;
$pts = new \InvoiceNinja\EInvoice\Models\Peppol\PartyTaxSchemeType\PartyTaxScheme();
$companyID = new \InvoiceNinja\EInvoice\Models\Peppol\IdentifierType\CompanyID();
$companyID->value = $this->override_vat_number ?? preg_replace("/[^a-zA-Z0-9]/", "", $this->invoice->company->settings->vat_number);
$companyID->value = strlen($this->override_vat_number ?? '') > 1 ? $this->override_vat_number : preg_replace("/[^a-zA-Z0-9]/", "", $this->invoice->company->settings->vat_number); //todo if we are cross border - switch to the supplier local vat number
$pts->CompanyID = $companyID;
$ts = new TaxScheme();
@@ -1498,9 +1501,9 @@ class Peppol extends AbstractService
$category_id->value = $this->getTaxType($grouped_tax['tax_id']); // Standard rate
// Temp fix for reduced tax rate categorization.
if($grouped_tax['tax_rate'] < 15 && $grouped_tax['tax_rate'] >= 0) {
$category_id->value = 'AA';
}
// if($grouped_tax['tax_rate'] < 15 && $grouped_tax['tax_rate'] >= 0) {
// $category_id->value = 'AA';
// }
$tax_category->ID = $category_id;

View File

@@ -30,6 +30,7 @@ parameters:
- \Stripe\Collection
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#\Saxon\SaxonProcessor#'
- '#Array has 2 duplicate keys with value#'
- '#Call to an undefined method#'
- '#makeHidden#'