From b669eb960ef16e499a72a880eb0f97af9894bd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= Date: Wed, 15 Jun 2022 12:02:24 +0200 Subject: [PATCH] Fixed tax registration ID without scheme - Updated UblWriter class - Updated unit tests > Closes #26 --- src/Writers/UblWriter.php | 4 +++- tests/Writers/UblWriterTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Writers/UblWriter.php b/src/Writers/UblWriter.php index 225873d..b807d4f 100644 --- a/src/Writers/UblWriter.php +++ b/src/Writers/UblWriter.php @@ -398,9 +398,11 @@ private function addSellerOrBuyerNode(UXML $parent, Party $party) { if ($taxRegistrationId !== null) { $taxRegistrationNode = $xml->add('cac:PartyTaxScheme'); $taxRegistrationNode->add('cbc:CompanyID', $taxRegistrationId->getValue()); + + $taxRegistrationSchemeNode = $taxRegistrationNode->add('cac:TaxScheme'); $taxRegistrationScheme = $taxRegistrationId->getScheme(); if ($taxRegistrationScheme !== null) { - $taxRegistrationNode->add('cac:TaxScheme')->add('cbc:ID', $taxRegistrationScheme); + $taxRegistrationSchemeNode->add('cbc:ID', $taxRegistrationScheme); } } diff --git a/tests/Writers/UblWriterTest.php b/tests/Writers/UblWriterTest.php index 2623e10..5cd3336 100644 --- a/tests/Writers/UblWriterTest.php +++ b/tests/Writers/UblWriterTest.php @@ -38,6 +38,7 @@ private function getSampleInvoice(): Invoice { $seller = (new Party) ->setElectronicAddress(new Identifier('9482348239847239874', '0088')) ->setCompanyId(new Identifier('COMPANY_ID', '0183')) + ->setTaxRegistrationId(new Identifier('12345678')) // NOTE: Missing scheme on purpose ->setName('Seller Name Ltd.') ->setTradingName('Seller Name') ->setVatNumber('ESA00000000')