Using the Mustang classes

Simple invoice

There is one test file which you can use for further reference, one on the XRechnung and one regarding the invoice importer.
First there is the construction and configuration of an exporter, which loads the PDF/A-file to attach the invoice to:


ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application").setCreator(System.getProperty("user.name")).ignorePDFAErrors().load(SOURCE_PDF));

Then you do the same with your invoice, which has a lot more configuration:


ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(new BankDetails("777666555", "DE4321"))).setOwnTaxID("4711").setOwnVATID("DE19990815")
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")
.setContact(new Contact("nameRep", "phoneRep", "emailRep@test.com"))).setNumber("X12")
.addItem(new Item(new Product("Testproduct", "", "C62", new BigDecimal(19)), new BigDecimal(2.5), new BigDecimal(1.0))));

You can chain several addItem behind one another. In this case we have an invoice numbered “X12” with a 1.0 times 19%, 2.5€ “Testproduct” in the unit “piece”(C62, refer to the sheet units in this list) with 19% VAT.
Now export it


ze.export("factur-x.pdf");

That’s it. Feel free to validate it and please make sure the calculated amounts in the XML match those in your PDF.

Corrected invoice

To revoke and reissue an issue send a corrected invoice, use a negative quantity on the items to be revoked and use setCorrection referring to the number of the invoice. The negative quantity will also mean a negative grand total. The following will nullify the previous invoice:


ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(new BankDetails("777666555", "DE4321"))).setOwnTaxID("4711").setOwnVATID("DE19990815")
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")
.setContact(new Contact("nameRep", "phoneRep", "emailRep@test.com"))).setNumber("X13")
.addItem(new Item(new Product("Testproduct", "", "C62", new BigDecimal(19)), new BigDecimal("2.5"), new BigDecimal(-1.0))).setCorrection("X12"));

Charges and allowances

Charges and allowances can be on document level or on item level, and they can be absolute amounts or percentual. They need to indicate which VAT rate they refer to and some profiles like EN16931 don’t allow charges on item level.

For a 50% charge on item level if the item is 19% VAT you can use


.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)).addCharge(new Charge().setPercent(new BigDecimal(50)).setTaxPercent(new BigDecimal(19))))

and for a 10€ allowance on document level chain the following on the invoice object:


.addAllowance(new Allowance(new BigDecimal(10)).setTaxPercent(new BigDecimal(19)))