Closed phax closed 4 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.
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);
}
@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
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:
setDefaultOrderRefID(String)
--ubl-defaultorderrefid
Is part of the upcoming v2.2.2 release
It seems, that if there exists BT-14 in CII, BT-13 will be generated, even if it not exists