ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

ZUGFeRDImporter does not offer SellerTradeParty:Name #396

Closed melo0187 closed 1 week ago

melo0187 commented 1 week ago

I have a file named XRECHNUNG_Elektron.pdf as an example for a ZUGFeRD 2.2 invoice, which seems to be equivalent to library/src/test/resources/XRECHNUNG_Elektron.ubl.xml. The xrechnung.xml that is embedded in the PDF contains SellerTradeParty:Name. However ZUGFeRDImporter does not expose a getter for this property.

Are there plans on adding this? Should I just open a PR to add the getter myself? On first look it might be a trivial adaptation of org.mustangproject.ZUGFeRD.ZUGFeRDImporter#getSellerTradePartyGlobalID.

jstaerk commented 1 week ago

Hello, feel free to PR but the recommended solution would be the much more sophisticated ZUGFeRDInvoiceImporter where you should be able to get it via sth like getRecipient(). PS: it may be "equivalent" but if you have a ZUGFeRD (PDF) you should expect a CII file inside, but XRECHNUNG_Elektron.ubl.xml is the UBL equivalent

melo0187 commented 1 week ago

Hello, feel free to PR but the recommended solution would be the much more sophisticated ZUGFeRDInvoiceImporter where you should be able to get it via sth like getRecipient(). PS: it may be "equivalent" but if you have a ZUGFeRD (PDF) you should expect a CII file inside, but XRECHNUNG_Elektron.ubl.xml is the UBL equivalent

@jstaerk thank you for your input! Much appreciated. I stumbled on the ZUGFeRDInvoiceImporter and wanted to look into it just yesterday. So I now have even more reason to do so =)

Also, thank you for pointing out that I'm dealing with a CII file in the case of ZUGFeRD. I meant that the files represent the same invoice. However, I am wondering how I would deal with a UBL file. Is there any support for this XRechnung format or do I need to go down another path to handle UBL?

melo0187 commented 1 week ago

For the record: I looked into ZUGFeRDInvoiceImporter. It extends ZUGFeRDImporter, so it offers all the same access methods. To me the main difference seems to be in ZUGFeRDInvoiceImporter#extractInvoice, which reads the data into an Invoice object. This object has getters like org.mustangproject.Invoice#getSender, which in turn has org.mustangproject.TradeParty#getName. So using ZUGFeRDInvoiceImporter to extract the data into an Invoice object does indeed solve my issue of missing access to the SellerTradeParty's name, which is why I close this issue. Thanks again @jstaerk for pointing me into the right direction.

However, I noticed some discrepancies for the same invoice file between reading data using an Invoice object from ZUGFeRDInvoiceImporter and reading the same data using ZUGFeRDImporter's methods. I will open new issues to investigate this further.

melo0187 commented 1 week ago

Also worth noting, following up on my question how to handle UBL: It seems as ZUGFeRDInvoiceImporter will happily take UBL files.