Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] CountryID Rendering PROFILE_MINIMUM #66

Closed
OLLIVAULT opened this issue May 29, 2024 · 6 comments
Closed

[BUG] CountryID Rendering PROFILE_MINIMUM #66

OLLIVAULT opened this issue May 29, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@OLLIVAULT
Copy link
Contributor

OLLIVAULT commented May 29, 2024

Describe the bug
There is an issue with the countryID of the profile; no matter what I do, the 2-letter code does not appear.

<ram:PostalTradeAddress>
          <ram:CountryID>XX</ram:CountryID>
</ram:PostalTradeAddress>

This renders as:

<ram:PostalTradeAddress/>
@OLLIVAULT OLLIVAULT added the bug Something isn't working label May 29, 2024
@horstoeko
Copy link
Owner

Hi @OLLIVAULT,

Please provide me the full code...

@OLLIVAULT
Copy link
Contributor Author

OLLIVAULT commented May 29, 2024

Here is the creation of the document

$document = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_MINIMUM);
            $document
                ->setDocumentBusinessProcess("A1")
                ->setDocumentInformation("5", "80", new DateTime("2024-02-02"), "5")
                ->setDocumentBuyerReference("5")
                ->setDocumentBuyerOrderReferencedDocument("5")
                ->setDocumentSeller("5")
                ->setDocumentSellerLegalOrganisation("5", null, null)
                ->addDocumentSellerTaxRegistration(null, "5")
                ->setDocumentSellerAddress(null, null, null, null, null, "FR")
                ->setDocumentBuyerLegalOrganisation("5", null, null)
                ->setDocumentBuyer("5", null)
                ->setDocumentSummation("5", "5", null, null, null, "5", "5")
                ->writeFile(__DIR__ . "/factur-x-minimum.xml");

and the XML output:

<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:10" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <rsm:ExchangedDocumentContext>
    <ram:BusinessProcessSpecifiedDocumentContextParameter>
      <ram:ID>A1</ram:ID>
    </ram:BusinessProcessSpecifiedDocumentContextParameter>
    <ram:GuidelineSpecifiedDocumentContextParameter>
      <ram:ID>urn:factur-x.eu:1p0:minimum</ram:ID>
    </ram:GuidelineSpecifiedDocumentContextParameter>
  </rsm:ExchangedDocumentContext>
  <rsm:ExchangedDocument>
    <ram:ID>5</ram:ID>
    <ram:TypeCode>80</ram:TypeCode>
    <ram:IssueDateTime>
      <udt:DateTimeString format="102">20240202</udt:DateTimeString>
    </ram:IssueDateTime>
  </rsm:ExchangedDocument>
  <rsm:SupplyChainTradeTransaction>
    <ram:ApplicableHeaderTradeAgreement>
      <ram:BuyerReference>5</ram:BuyerReference>
      <ram:SellerTradeParty>
        <ram:Name>5</ram:Name>
        <ram:SpecifiedLegalOrganization>
          <ram:ID>5</ram:ID>
        </ram:SpecifiedLegalOrganization>
        <ram:PostalTradeAddress/>
      </ram:SellerTradeParty>
      <ram:BuyerTradeParty>
        <ram:Name>5</ram:Name>
      </ram:BuyerTradeParty>
      <ram:BuyerOrderReferencedDocument>
        <ram:IssuerAssignedID>5</ram:IssuerAssignedID>
      </ram:BuyerOrderReferencedDocument>
    </ram:ApplicableHeaderTradeAgreement>
    <ram:ApplicableHeaderTradeDelivery/>
    <ram:ApplicableHeaderTradeSettlement>
      <ram:InvoiceCurrencyCode>5</ram:InvoiceCurrencyCode>
      <ram:SpecifiedTradeSettlementHeaderMonetarySummation>
        <ram:TaxBasisTotalAmount>5.00</ram:TaxBasisTotalAmount>
        <ram:TaxTotalAmount currencyID="5">5.00</ram:TaxTotalAmount>
        <ram:GrandTotalAmount>5.00</ram:GrandTotalAmount>
        <ram:DuePayableAmount>5.00</ram:DuePayableAmount>
      </ram:SpecifiedTradeSettlementHeaderMonetarySummation>
    </ram:ApplicableHeaderTradeSettlement>
  </rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>

If I change PROFILE_MINIMUM to another one, then the CountryID is displayed.

@danielmarschall
Copy link
Contributor

danielmarschall commented May 29, 2024

Forget my previous posts; here is the correct bugfix:

ZugferdObjectHelper.php

Search
$this->tryCall($address, "setCountryID", $this->getCodeType($country));

Replace:
$this->tryCall($address, "setCountryID", $this->getCountryIDType($country));

Explanation: The schema minimum does not contain udt:CodeType. Its definition of TradeAddressType is

  <xs:complexType name="TradeAddressType">
    <xs:sequence>
      <xs:element name="CountryID" type="qdt:CountryIDType"/>
    </xs:sequence>
  </xs:complexType>

For all other schemes, the definition is the same: <xs:element name="CountryID" type="qdt:CountryIDType"/> , not udt:CodeType

@horstoeko
Copy link
Owner

Hi @OLLIVAULT,

brilliant... I totally overlooked that. Very good work!!! Do you want to create a PR or should I fix it on my own?

@danielmarschall
Copy link
Contributor

I submitted PR #69 (but credits for the fix go to me :-) )

@danielmarschall
Copy link
Contributor

Sorry, I overlooked that PR #68 already existed!

horstoeko added a commit that referenced this issue May 29, 2024
Fixed problem with Country ID at profile minimum (Fixes #66)
Repository owner locked as resolved and limited conversation to collaborators May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants