Skip to content

Commit

Permalink
Merge pull request #27 from josemmo/develop
Browse files Browse the repository at this point in the history
Fixed tax registration ID without scheme
  • Loading branch information
josemmo authored Jun 22, 2022
2 parents c4a1d1b + b669eb9 commit 353321f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Writers/UblWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Writers/UblWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 353321f

Please sign in to comment.