phax / en16931-cii2ubl

Converter for EN16931 invoices from CII to UBL
Apache License 2.0
18 stars 6 forks source link

BT-14 in CII -> BT-13 in UBL check #23

Closed phax closed 4 months ago

phax commented 6 months ago

It seems, that if there exists BT-14 in CII, BT-13 will be generated, even if it not exists

lkumai commented 5 months ago

I went deeper into this matter and could narrow down the "bug" to class OrderReferenceType of ph-ubl21-9.0.1. It seems, that /Invoice/cac:OrderReference/cbc:ID is a required element:

@XmlElement(name = "ID", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2", required = true)
    private IDType id;

Then I looked into the scheme and the syntax binding and /Invoice/cac:OrderReference/cbc:ID which is mapped to BT-13 is indeed a required element. So this issue here is not a bug in my opinion.

Maybe filling it with a placeholder can be a workaround, but it would change the invoice a little bit.

lkumai commented 5 months ago

I've implemented the workaround in CIItoUBL21Converter.java at line 712:

// OrderReference
    {
      final OrderReferenceType aUBLOrderRef = _createUBLOrderRef (aHeaderAgreement.getBuyerOrderReferencedDocument (),
                                                                  aHeaderAgreement.getSellerOrderReferencedDocument ());

      /* Set BT-13 with a hyhen if it is empty */
      if(aUBLOrderRef != null) 
      {
        if(aUBLOrderRef.getIDValue().equals("")) 
        {
          aUBLOrderRef.setID("-");
        }
      }
      aUBLInvoice.setOrderReference (aUBLOrderRef);
    }
phax commented 5 months ago

@lkumai I checked the existing code, and that branch is already contained. Instead of setting a - an empty string "" is created. That alone is XSD compliant. So your issue was already solved in the latest release 2.2.1 - please crosscheck. My test was positive

phax commented 4 months ago

The problem is not just, that it is required, but also that it must not be empty. To resolve this, I added the possibility to customize the value:

phax commented 4 months ago

Is part of the upcoming v2.2.2 release