diff --git a/History.md b/History.md index 0db265cc..f1bad23a 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,11 @@ - Corrected forgotten --d CLI shortcut - No uber jar #297 - automated server tests +- prevent nullpointerexception https://github.com/ZUGFeRD/mustangproject/pull/302 thanks to weclapp-dev +- lines no longer included in basic-wl and minimum +- due date and delivery date no longer mandatory for credit notes +- Allow foreign limited addresses, e.g. allow Parties withpout postal addresses/postcodes +- Allow invoices in minimum profile e.g. dont use applicabletradetax, linetotalamount, paymentreference etc in Minimum profile 2.5.7 ======= diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 9e561392..f79ba6d4 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -21,7 +21,6 @@ package org.mustangproject.ZUGFeRD; import static org.mustangproject.ZUGFeRD.ZUGFeRDDateFormat.DATE; -import static org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE; import static org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants.CATEGORY_CODES_WITH_EXEMPTION_REASON; import java.io.IOException; @@ -43,6 +42,7 @@ import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; import org.mustangproject.FileAttachment; import org.mustangproject.XMLTools; +import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; public class ZUGFeRD2PullProvider implements IXMLProvider { @@ -166,9 +166,12 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += ""; } - xml += "" - + "" + XMLTools.encodeXML(party.getZIP()) - + ""; + + xml += ""; + if (party.getZIP() != null) { + xml += "" + XMLTools.encodeXML(party.getZIP()) + + ""; + } if (party.getStreet() != null) { xml += "" + XMLTools.encodeXML(party.getStreet()) + ""; @@ -181,11 +184,16 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(party.getAdditionalAddressExtension()) + ""; } - xml += "" + XMLTools.encodeXML(party.getLocation()) - + "" - + "" + XMLTools.encodeXML(party.getCountry()) + if (party.getLocation() != null) { + xml += "" + XMLTools.encodeXML(party.getLocation()) + + ""; + } + ; +//country IS mandatory + xml += "" + XMLTools.encodeXML(party.getCountry()) + "" + ""; + if ((party.getVATID() != null) && (!isShipToTradeParty)) { xml += "" + "" + XMLTools.encodeXML(party.getVATID()) @@ -233,7 +241,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { ""; return allowanceChargeStr; } - + /*** * returns the XML for a charge or allowance on item total level * @param allowance the allowance or charge @@ -250,7 +258,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (allowance.isCharge()) { chargeIndicator = "true"; } - + final String itemTotalAllowanceChargeStr = "" + chargeIndicator + "" + percentage + "" + currencyFormat(allowance.getTotalAmount(item)) + "" + @@ -270,10 +278,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { String exemptionReason = ""; if (trans.getPaymentTermDescription() != null) { - paymentTermsDescription = XMLTools.encodeXML(trans.getPaymentTermDescription()); + paymentTermsDescription = XMLTools.encodeXML(trans.getPaymentTermDescription()); } - if ((paymentTermsDescription == null) && (trans.getDocumentCode() != CORRECTEDINVOICE)/* && (trans.getDocumentCode() != DocumentCodeTypeConstants.CREDITNOTE)*/) { + if ((paymentTermsDescription == null) && (trans.getDocumentCode() != DocumentCodeTypeConstants.CORRECTEDINVOICE) && (trans.getDocumentCode() != DocumentCodeTypeConstants.CREDITNOTE)) { paymentTermsDescription = "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()); } @@ -357,123 +365,126 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } } final LineCalculator lc = new LineCalculator(currentItem); - xml += "" + - "" - + "" + lineID + "" - + notes - + "" - - + ""; - if ((currentItem.getProduct().getGlobalIDScheme() != null) && (currentItem.getProduct().getGlobalID() != null)) { - xml += ""+XMLTools.encodeXML(currentItem.getProduct().getGlobalID())+""; - } - - if (currentItem.getProduct().getSellerAssignedID() != null) { - xml += "" - + XMLTools.encodeXML(currentItem.getProduct().getSellerAssignedID()) + ""; - } - if (currentItem.getProduct().getBuyerAssignedID() != null) { - xml += "" - + XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + ""; - } - String allowanceChargeStr = ""; - if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) { - for (final IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) { - allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem); - } - } - if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) { - for (final IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) { - allowanceChargeStr += getAllowanceChargeStr(charge, currentItem); - - } - } - - String itemTotalAllowanceChargeStr = ""; - if (currentItem.getItemTotalAllowances() != null && currentItem.getItemTotalAllowances().length > 0) { - for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getItemTotalAllowances()) { - itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalAllowance, currentItem); - } - } - - xml += "" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "" - + "" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) - + "" - + "" - - + ""; - if (currentItem.getReferencedDocuments() != null) { - for (final IReferencedDocument currentReferencedDocument : currentItem.getReferencedDocuments()) { - xml += "" + - "" + XMLTools.encodeXML(currentReferencedDocument.getIssuerAssignedID()) + "" + - "" + XMLTools.encodeXML(currentReferencedDocument.getTypeCode()) + "" + - "" + XMLTools.encodeXML(currentReferencedDocument.getReferenceTypeCode()) + "" + - ""; + if ((getProfile() != Profiles.getByName("Minimum")) && (getProfile() != Profiles.getByName("BasicWL"))) { + xml += "" + + "" + + "" + lineID + "" + + notes + + "" + + ""; + if ((currentItem.getProduct().getGlobalIDScheme() != null) && (currentItem.getProduct().getGlobalID() != null)) { + xml += "" + XMLTools.encodeXML(currentItem.getProduct().getGlobalID()) + ""; } - } - if (currentItem.getBuyerOrderReferencedDocumentLineID() != null) { - xml += " " - + "" + XMLTools.encodeXML(currentItem.getBuyerOrderReferencedDocumentLineID()) + "" - + ""; - - } - xml += "" - + "" + priceFormat(lc.getPriceGross()) - + "" //currencyID=\"EUR\" - + "" + quantityFormat(currentItem.getBasisQuantity()) + "" - + allowanceChargeStr - // + " " - // + " false" - // + " 0.6667" - // + " Rabatt" - // + " " - + "" - + "" - + "" + priceFormat(lc.getPrice()) - + "" // currencyID=\"EUR\" - + "" + quantityFormat(currentItem.getBasisQuantity()) + "" - + "" - + "" - + "" - + "" - + quantityFormat(currentItem.getQuantity()) + "" - + "" - + "" - + "" - + "VAT" - + exemptionReason - + "" + currentItem.getProduct().getTaxCategoryCode() + "" - + "" - + vatFormat(currentItem.getProduct().getVATPercent()) + "" - + ""; - if ((currentItem.getDetailedDeliveryPeriodFrom() != null) || (currentItem.getDetailedDeliveryPeriodTo() != null)) { - xml += ""; - if (currentItem.getDetailedDeliveryPeriodFrom() != null) { - xml += "" + DATE.udtFormat(currentItem.getDetailedDeliveryPeriodFrom()) + ""; + if (currentItem.getProduct().getSellerAssignedID() != null) { + xml += "" + + XMLTools.encodeXML(currentItem.getProduct().getSellerAssignedID()) + ""; } - if (currentItem.getDetailedDeliveryPeriodTo() != null) { - xml += "" + DATE.udtFormat(currentItem.getDetailedDeliveryPeriodTo()) + ""; + if (currentItem.getProduct().getBuyerAssignedID() != null) { + xml += "" + + XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + ""; } - xml += ""; - } - - xml += itemTotalAllowanceChargeStr; - - xml += "" - + "" + currencyFormat(lc.getItemTotalNetAmount()) - + "" // currencyID=\"EUR\" - + ""; - if (currentItem.getAdditionalReferencedDocumentID() != null) { - xml += "" + currentItem.getAdditionalReferencedDocumentID() + "130"; + String allowanceChargeStr = ""; + if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) { + for (final IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) { + allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem); + } + } + if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) { + for (final IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) { + allowanceChargeStr += getAllowanceChargeStr(charge, currentItem); + } + } + + String itemTotalAllowanceChargeStr = ""; + if (currentItem.getItemTotalAllowances() != null && currentItem.getItemTotalAllowances().length > 0) { + for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getItemTotalAllowances()) { + itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalAllowance, currentItem); + } + } + + xml += "" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "" + + "" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) + + "" + + "" + + + ""; + if (currentItem.getReferencedDocuments() != null) { + for (final IReferencedDocument currentReferencedDocument : currentItem.getReferencedDocuments()) { + xml += "" + + "" + XMLTools.encodeXML(currentReferencedDocument.getIssuerAssignedID()) + "" + + "" + XMLTools.encodeXML(currentReferencedDocument.getTypeCode()) + "" + + "" + XMLTools.encodeXML(currentReferencedDocument.getReferenceTypeCode()) + "" + + ""; + + + } + + } + if (currentItem.getBuyerOrderReferencedDocumentLineID() != null) { + xml += " " + + "" + XMLTools.encodeXML(currentItem.getBuyerOrderReferencedDocumentLineID()) + "" + + ""; + + } + xml += "" + + "" + priceFormat(lc.getPriceGross()) + + "" //currencyID=\"EUR\" + + "" + quantityFormat(currentItem.getBasisQuantity()) + "" + + allowanceChargeStr + // + " " + // + " false" + // + " 0.6667" + // + " Rabatt" + // + " " + + "" + + "" + + "" + priceFormat(lc.getPrice()) + + "" // currencyID=\"EUR\" + + "" + quantityFormat(currentItem.getBasisQuantity()) + "" + + "" + + "" + + "" + + "" + + quantityFormat(currentItem.getQuantity()) + "" + + "" + + "" + + "" + + "VAT" + + exemptionReason + + "" + currentItem.getProduct().getTaxCategoryCode() + "" + + "" + + vatFormat(currentItem.getProduct().getVATPercent()) + "" + + ""; + if ((currentItem.getDetailedDeliveryPeriodFrom() != null) || (currentItem.getDetailedDeliveryPeriodTo() != null)) { + xml += ""; + if (currentItem.getDetailedDeliveryPeriodFrom() != null) { + xml += "" + DATE.udtFormat(currentItem.getDetailedDeliveryPeriodFrom()) + ""; + } + if (currentItem.getDetailedDeliveryPeriodTo() != null) { + xml += "" + DATE.udtFormat(currentItem.getDetailedDeliveryPeriodTo()) + ""; + } + xml += ""; + } + + xml += itemTotalAllowanceChargeStr; + + xml += "" + + "" + currencyFormat(lc.getItemTotalNetAmount()) + + "" // currencyID=\"EUR\" + + ""; + if (currentItem.getAdditionalReferencedDocumentID() != null) { + xml += "" + currentItem.getAdditionalReferencedDocumentID() + "130"; + + } + xml += "" + + ""; } - xml += "" - + ""; } @@ -528,51 +539,61 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (trans.getSpecifiedProcuringProjectID() != null) { xml += " " + " " - + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + ""; + + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + ""; if (trans.getSpecifiedProcuringProjectName() != null) { xml += " " + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + ""; } xml += " "; } - xml += "" - + ""; + xml += ""; + xml += ""; + if (this.trans.getDeliveryAddress() != null) { xml += "" + getTradePartyAsXML(this.trans.getDeliveryAddress(), false, true) + ""; } - xml += "" - + ""; if (trans.getDeliveryDate() != null) { + xml += "" + + ""; xml += DATE.udtFormat(trans.getDeliveryDate()); + xml += ""; + xml += " "; + } else { - throw new IllegalStateException("No delivery date provided"); + if (trans.getDocumentCode() != DocumentCodeTypeConstants.CREDITNOTE) { + throw new IllegalStateException("No delivery date provided"); + } } - xml += ""; - xml += " "; - /* - * + "" + - * "20130603" + - * "2013-51112" + - * "" - */ + /* + * + "" + + * "20130603" + + * "2013-51112" + + * "" + */ if (trans.getDespatchAdviceReferencedDocumentID() != null) { xml += ""; - xml += ""+XMLTools.encodeXML(trans.getDespatchAdviceReferencedDocumentID())+""; + xml += "" + XMLTools.encodeXML(trans.getDespatchAdviceReferencedDocumentID()) + ""; xml += ""; } - xml += " " - + " " + XMLTools.encodeXML(trans.getNumber()) + "" - + " " + trans.getCurrency() + ""; + + xml += ""; + xml += ""; + if ((trans.getNumber() != null) && (getProfile() != Profiles.getByName("Minimum"))) { + xml += " " + XMLTools.encodeXML(trans.getNumber()) + ""; + } + xml += " " + trans.getCurrency() + ""; if (trans.getTradeSettlementPayment() != null) { for (final IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) { if (payment != null) { hasDueDate = true; - xml += payment.getSettlementXML(); + if (getProfile() != Profiles.getByName("Minimum")) { + xml += payment.getSettlementXML(); + } } } } @@ -582,11 +603,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (payment instanceof IZUGFeRDTradeSettlementPayment) { hasDueDate = true; } - xml += payment.getSettlementXML(); + if (getProfile() != Profiles.getByName("Minimum")) { + xml += payment.getSettlementXML(); + } } } } - if ((trans.getDocumentCode() == CORRECTEDINVOICE)/*||(trans.getDocumentCode() == DocumentCodeTypeConstants.CREDITNOTE)*/) { + if ((trans.getDocumentCode() == DocumentCodeTypeConstants.CORRECTEDINVOICE) || (trans.getDocumentCode() == DocumentCodeTypeConstants.CREDITNOTE)) { hasDueDate = false; } @@ -596,15 +619,18 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (amount != null) { final String amountCategoryCode = amount.getCategoryCode(); final boolean displayExemptionReason = CATEGORY_CODES_WITH_EXEMPTION_REASON.contains(amountCategoryCode); - xml += "" - + "" + currencyFormat(amount.getCalculated()) - + "" //currencyID=\"EUR\" - + "VAT" - + (displayExemptionReason ? exemptionReason : "") - + "" + currencyFormat(amount.getBasis()) + "" // currencyID=\"EUR\" - + "" + amountCategoryCode + "" - + "" - + vatFormat(currentTaxPercent) + ""; + if (getProfile() != Profiles.getByName("Minimum")) { + + xml += "" + + "" + currencyFormat(amount.getCalculated()) + + "" //currencyID=\"EUR\" + + "VAT" + + (displayExemptionReason ? exemptionReason : "") + + "" + currencyFormat(amount.getBasis()) + "" // currencyID=\"EUR\" + + "" + amountCategoryCode + "" + + "" + + vatFormat(currentTaxPercent) + ""; + } } } if ((trans.getDetailedDeliveryPeriodFrom() != null) || (trans.getDetailedDeliveryPeriodTo() != null)) { @@ -660,7 +686,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } - if ((trans.getPaymentTerms() == null) && ((paymentTermsDescription != null) || (trans.getTradeSettlement() != null) || (hasDueDate))) { + if ((trans.getPaymentTerms() == null) && (getProfile() != Profiles.getByName("Minimum")) && ((paymentTermsDescription != null) || (trans.getTradeSettlement() != null) || (hasDueDate))) { xml += ""; if (paymentTermsDescription != null) { @@ -691,20 +717,24 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { final String chargesTotalLine = "" + currencyFormat(calc.getChargesForPercent(null)) + ""; - xml += "" - + "" + currencyFormat(calc.getTotal()) + "" - + chargesTotalLine - + allowanceTotalLine - + "" + currencyFormat(calc.getTaxBasis()) + "" + xml += ""; + if (getProfile() != Profiles.getByName("Minimum")) { + xml += "" + currencyFormat(calc.getTotal()) + ""; + xml += chargesTotalLine + + allowanceTotalLine; + } + xml += "" + currencyFormat(calc.getTaxBasis()) + "" // // // currencyID=\"EUR\" + "" + currencyFormat(calc.getGrandTotal().subtract(calc.getTaxBasis())) + "" - + "" + currencyFormat(calc.getGrandTotal()) + "" + + "" + currencyFormat(calc.getGrandTotal()) + ""; // // // currencyID=\"EUR\" - + " " + currencyFormat(calc.getTotalPrepaid()) + "" - + "" + currencyFormat(calc.getGrandTotal().subtract(calc.getTotalPrepaid())) + "" + if (getProfile() != Profiles.getByName("Minimum")) { + xml+=" " + currencyFormat(calc.getTotalPrepaid()) + ""; + } + xml+= "" + currencyFormat(calc.getGrandTotal().subtract(calc.getTotalPrepaid())) + "" + ""; if (trans.getInvoiceReferencedDocumentID() != null) { xml += " " @@ -713,7 +743,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (trans.getInvoiceReferencedIssueDate() != null) { xml += "" + DATE.qdtFormat(trans.getInvoiceReferencedIssueDate()) - + ""; + + ""; } xml += " "; } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java new file mode 100644 index 00000000..ea4f6067 --- /dev/null +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java @@ -0,0 +1,96 @@ +/** + * ********************************************************************* + *

+ * Copyright 2019 Jochen Staerk + *

+ * Use is subject to license terms. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0. + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *

+ * See the License for the specific language governing permissions and + * limitations under the License. + *

+ * ********************************************************************** + */ +package org.mustangproject.ZUGFeRD; + +import junit.framework.TestCase; +import org.mustangproject.*; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/*** + * This is a test to confirm the minimum steps to implement a interface are still sufficient + * + * @author jstaerk + * + */ +public class ProfilesMinimumBasicWLTest extends TestCase { + + final String TARGET_PDF_FX_MINIMUM = "./target/testout-Minimum.pdf"; + + public void testMinimumExport() { + String ownNumber = "NUMFACTURE"; + String ownBIC = "COBADEFFXXX"; + String ownIBAN = "DE88200800000970375700"; + String ownOrgName = "ME"; + + // the writing part + try (InputStream SOURCE_PDF = this.getClass() + .getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf"); + IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile("Minimum").load(SOURCE_PDF)) { + //https://stackoverflow.com/questions/72450066/creating-a-min-basic-and-basic-wl-factur-x-using-mustang + Invoice i = new Invoice() + .setIssueDate(new Date()) +/* .setDueDate(new Date()) + .setDetailedDeliveryPeriod(new Date(), new Date()) + .setDeliveryDate(new Date())*/ + .setSender( + new TradeParty().setName(ownOrgName).setCountry("FR") + .addBankDetails(new BankDetails(ownIBAN, ownBIC))) + .setRecipient( + new TradeParty().setName("Client").setCountry("FR")) + .setNumber(ownNumber) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(123), new BigDecimal(1))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(123), new BigDecimal(1))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(123), new BigDecimal(1))) + .setCreditNote(); + ze.setTransaction(i); + ze.export(TARGET_PDF_FX_MINIMUM); + + // check for pdf-a schema extension +// assertFalse(pdfContent.indexOf("EN 16931") == -1); +// assertFalse(pdfContent.indexOf("zf") == -1); +// assertFalse(pdfContent.indexOf("urn:zugferd:pdfa:CrossIndustryDocument:invoice:2p0#") == -1); + + } catch (IOException e) { + fail("IOException should not happen in testZExport"); + } + + // now check the contents (like MustangReaderTest) + ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF_FX_MINIMUM); + + // Reading ZUGFeRD + assertEquals(zi.getAmount(), "439.11"); +// assertEquals(zi.getBIC(), ownBIC); +// assertEquals(zi.getIBAN(), ownIBAN); + assertEquals(zi.getHolder(), ownOrgName); +// assertEquals(zi.getForeignReference(), ownNumber); + + + } + + +} diff --git a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java index 45b1df19..a905bb01 100644 --- a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java +++ b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java @@ -248,9 +248,29 @@ public class LibraryTest extends ResourceCase { assertThat(res).valueByXPath("count(//notice)") .asInt() .isEqualTo(0); + } + + public void testMinimumProfileValidity() { + File tempFile = new File("../library/target/testout-Minimum.pdf"); + ZUGFeRDValidator zfv = new ZUGFeRDValidator(); + + String res = zfv.validate(tempFile.getAbsolutePath()); + + assertThat(res).valueByXPath("count(//error)") + .asInt() + .isEqualTo(0); + assertThat(res).valueByXPath("/validation/summary/@status") + .asString() + .isEqualTo("valid");// expect to be valid because XR notices are, well, only notices + assertThat(res).valueByXPath("/validation/xml/summary/@status") + .asString() + .isEqualTo("valid"); + /** end of errors due to version mismatch*/ - + assertThat(res).valueByXPath("count(//notice)") + .asInt() + .isEqualTo(0); } }