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

V2.15.0: Extract Information from the Importer #592

Open
schuettef opened this issue Nov 27, 2024 · 0 comments
Open

V2.15.0: Extract Information from the Importer #592

schuettef opened this issue Nov 27, 2024 · 0 comments

Comments

@schuettef
Copy link

Hey

after the Update to 2.15. we use the new ZugferdInvoiceImporter instead of ZugferdImporter (old). The handling is very difficult. Its important for us to export all information from the Document. The old one was very easy at this point and had lots of getter - and also a method to export own strings. This is now protected :( -> protected String extractString(String xpathStr): ZUGFeRDInvoiceImporter.java:756

Can you help as to convert it to the new importer:
For example we cant find this:
importer.getIssuerAssignedID()
in Item.java:86 is the sibling lineID but not IssuerAssignedID.

Thats our list:

Map<String, String> meta = new HashMap<>();
ZUGFeRDImporter importer = new ZUGFeRDImporter(is);

meta.add("BIC", importer.getBIC());
      meta.add("zugferd-version", "" + importer.getVersion());
      meta.add("Amount", importer.getAmount());
      meta.add("BankName", importer.getBankName());
      meta.add("BuyerTradePartyGlobalID", importer.getBuyerTradePartyGlobalID());
      meta.add("BuyerTradePartyID", importer.getBuyerTradePartyID());
      meta.add("BuyerTradePartyName", importer.getBuyerTradePartyName());
      meta.add("BuyertradePartySpecifiedTaxRegistrationID", importer.getBuyertradePartySpecifiedTaxRegistrationID());
      meta.add("BuyerTradePartyAddress", address(importer.getBuyerTradePartyAddress()));
      meta.add("DocumentCode", importer.getDocumentCode());
      meta.add("ForeignReference", importer.getForeignReference());
      meta.add("Holder", importer.getHolder());
      meta.add("IncludedNote", importer.getIncludedNote());
      meta.add("InvoiceCurrencyCode", importer.getInvoiceCurrencyCode());
      meta.add("InvoiceID", importer.getInvoiceID());
      meta.add("IssueDate", importer.getIssueDate());
      meta.add("IssuerAssignedID", importer.getIssuerAssignedID());
      meta.add("LineTotalAmount", importer.getLineTotalAmount());
      meta.add("PaidAmount", importer.getPaidAmount());
      meta.add("PaymentTerms", importer.getPaymentTerms());
      meta.add("Reference", importer.getReference());
      meta.add("RoundingAmount", importer.getRoundingAmount());
      meta.add("SellerTradePartyGlobalID", importer.getSellerTradePartyGlobalID());
      meta.add("SellerTradePartyAddress", address(importer.getSellerTradePartyAddress()));
      meta.add("TaxBasisTotalAmount", importer.getTaxBasisTotalAmount());
      meta.add("TaxPointDate", importer.getTaxPointDate());
      meta.add("TaxTotalAmount", importer.getTaxTotalAmount());
      meta.add("ZUGFeRDProfil", importer.getZUGFeRDProfil());
      meta.add("XMP", importer.getXMP());
      meta.add("DueDate", importer.getDueDate());     

The old importer get a two NullpointerException:

getDueDate():

	public String getDueDate() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		return sdf.format(importedInvoice.getDueDate());
	}

importedInvoice.getDueDate() returns null, because there is no entry in the XML. But for the SimpleDateFormat its nessary to have it -> Objects.requireNonNull(date, "date must not be null");
I only can fix it with try/catch. This is can't be right ?

The new one returns null - this is fine.

getIBAN():

	public String getIBAN() {
		for (IZUGFeRDTradeSettlement settlement : importedInvoice.getTradeSettlement()) {
			if (settlement instanceof IZUGFeRDTradeSettlementDebit) {
				return ((IZUGFeRDTradeSettlementDebit) settlement).getIBAN();
			}
			if (settlement instanceof IZUGFeRDTradeSettlementPayment) {
				return ((IZUGFeRDTradeSettlementPayment) settlement).getOwnIBAN();
			}
		}
		return null;
	}

importedInvoice.getTradeSettlement() returns null in several places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant