preliminary updates
This commit is contained in:
@@ -27,6 +27,7 @@ switch
|
|||||||
- javadoc export
|
- javadoc export
|
||||||
- have visualizer
|
- have visualizer
|
||||||
|
|
||||||
|
|
||||||
### 2.0 still todo
|
### 2.0 still todo
|
||||||
- release notes
|
- release notes
|
||||||
- verapdf as prevalidation?
|
- verapdf as prevalidation?
|
||||||
@@ -41,11 +42,17 @@ switch
|
|||||||
- *visualizer tests
|
- *visualizer tests
|
||||||
- *validator not to log to stdout
|
- *validator not to log to stdout
|
||||||
- *validator not to XR error on ZF files (only notices)
|
- *validator not to XR error on ZF files (only notices)
|
||||||
|
- *from A3 does not seem tow ork see mustangreaderwriteredgetest:testedgeexport
|
||||||
- xmp errors may not show correctly in log
|
- xmp errors may not show correctly in log
|
||||||
- switch for no log and no notices
|
- switch for no log and no notices
|
||||||
- merge readmes and history.md
|
- merge readmes and history.md
|
||||||
- homepage to be updated accordingly
|
- homepage to be updated accordingly
|
||||||
- confirm correct generation from pdf/a3 files zf2edgetest
|
- confirm correct generation from pdf/a3 files zf2edgetest
|
||||||
|
- *correctiontest exports zf1+zf2?
|
||||||
|
- *use validator in tests of library
|
||||||
|
- *invoiceprovider currencyid missing
|
||||||
|
- *USt 0% wird aus invoice-klasse noch nicht sauber abgefangen
|
||||||
|
- *ownContact sollte in einen Contact schreiben
|
||||||
|
|
||||||
1.7.7
|
1.7.7
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ public class Main {
|
|||||||
System.out.println("ZUGFeRD XML source set to " + sourceName);
|
System.out.println("ZUGFeRD XML source set to " + sourceName);
|
||||||
}
|
}
|
||||||
if (outName == null) {
|
if (outName == null) {
|
||||||
outName = getFilenameFromUser("ZUGFeRD 2.0 XML target", "factur-x.html", "html", false, true);
|
outName = getFilenameFromUser("ZUGFeRD 2.0 HTML target", "factur-x.html", "html", false, true);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("ZUGFeRD 1.0 XML source set to " + outName);
|
System.out.println("ZUGFeRD 1.0 XML source set to " + outName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
|
|
||||||
public Invoice() {
|
public Invoice() {
|
||||||
ZFItems = new ArrayList<IZUGFeRDExportableItem>();
|
ZFItems = new ArrayList<IZUGFeRDExportableItem>();
|
||||||
|
setCurrency("EUR");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public interface IExportableTransaction {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return Code of Document
|
* @return Code number of Document type, e.g. "380" for invoiceF
|
||||||
*/
|
*/
|
||||||
default String getDocumentCode() {
|
default String getDocumentCode() {
|
||||||
return DocumentCodeTypeConstants.INVOICE;
|
return DocumentCodeTypeConstants.INVOICE;
|
||||||
|
|||||||
@@ -43,26 +43,6 @@ public interface IZUGFeRDTradeSettlementPayment extends IZUGFeRDTradeSettlement
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BLZ of the sender
|
|
||||||
*
|
|
||||||
* @return the BLZ code of the recipient sender's bank
|
|
||||||
*/
|
|
||||||
default String getOwnBLZ() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bank name of the sender
|
|
||||||
*
|
|
||||||
* @return the name of the sender's bank
|
|
||||||
*/
|
|
||||||
default String getOwnBankName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBAN of the sender
|
* IBAN of the sender
|
||||||
*
|
*
|
||||||
@@ -73,25 +53,12 @@ public interface IZUGFeRDTradeSettlementPayment extends IZUGFeRDTradeSettlement
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IBAN of the sender
|
|
||||||
*
|
|
||||||
* @return the Account Number of the invoice sender's bank account
|
|
||||||
*/
|
|
||||||
default String getOwnKto() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
default String getSettlementXML() {
|
default String getSettlementXML() {
|
||||||
String xml = " <ram:SpecifiedTradeSettlementPaymentMeans>\n"
|
String xml = " <ram:SpecifiedTradeSettlementPaymentMeans>\n"
|
||||||
+ " <ram:TypeCode>42</ram:TypeCode>\n"
|
+ " <ram:TypeCode>42</ram:TypeCode>\n"
|
||||||
+ " <ram:Information>Überweisung</ram:Information>\n"
|
+ " <ram:Information>Überweisung</ram:Information>\n"
|
||||||
+ " <ram:PayeePartyCreditorFinancialAccount>\n"
|
+ " <ram:PayeePartyCreditorFinancialAccount>\n"
|
||||||
+ " <ram:IBANID>" + XMLTools.encodeXML(getOwnIBAN()) + "</ram:IBANID>\n"; //$NON-NLS-2$
|
+ " <ram:IBANID>" + XMLTools.encodeXML(getOwnIBAN()) + "</ram:IBANID>\n"; //$NON-NLS-2$
|
||||||
if (getOwnKto()!=null) {
|
|
||||||
xml+= " <ram:ProprietaryID>" + XMLTools.encodeXML(getOwnKto()) + "</ram:ProprietaryID>\n"; //$NON-NLS-2$
|
|
||||||
|
|
||||||
}
|
|
||||||
xml+= " </ram:PayeePartyCreditorFinancialAccount>\n"
|
xml+= " </ram:PayeePartyCreditorFinancialAccount>\n"
|
||||||
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
||||||
+ " <ram:BICID>" + XMLTools.encodeXML(getOwnBIC()) + "</ram:BICID>\n" //$NON-NLS-2$
|
+ " <ram:BICID>" + XMLTools.encodeXML(getOwnBIC()) + "</ram:BICID>\n" //$NON-NLS-2$
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
|||||||
return xmlProvider;
|
return xmlProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZUGFeRDExporterFromA3 addAdditionalFile(String name, byte[] content) {
|
||||||
|
|
||||||
|
additionalFiles.put(name,content);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* internal helper function: get namespace for given zugferd or factur-x version
|
* internal helper function: get namespace for given zugferd or factur-x version
|
||||||
@@ -512,6 +517,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
|||||||
PDFAttachGenericFile(doc, filename, "Alternative",
|
PDFAttachGenericFile(doc, filename, "Alternative",
|
||||||
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
||||||
"text/xml", xmlProvider.getXML());
|
"text/xml", xmlProvider.getXML());
|
||||||
|
|
||||||
for (String filenameAdditional : additionalFiles.keySet()) {
|
for (String filenameAdditional : additionalFiles.keySet()) {
|
||||||
PDFAttachGenericFile(doc, filenameAdditional, "Supplement", "ZUGFeRD extension/additional data", "text/xml", additionalFiles.get(filenameAdditional));
|
PDFAttachGenericFile(doc, filenameAdditional, "Supplement", "ZUGFeRD extension/additional data", "text/xml", additionalFiles.get(filenameAdditional));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,11 +198,6 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
|
|||||||
return "bla";
|
return "bla";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnBankName() {
|
|
||||||
return "bla";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnIBAN() {
|
public String getOwnIBAN() {
|
||||||
return "bla";
|
return "bla";
|
||||||
|
|||||||
@@ -27,26 +27,11 @@ public class IZUGFeRDTradeSettlementPaymentImpl implements IZUGFeRDTradeSettleme
|
|||||||
private String ownIBAN;
|
private String ownIBAN;
|
||||||
private String ownPaymentInfoText;
|
private String ownPaymentInfoText;
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnKto() {
|
|
||||||
return ownKto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnBLZ() {
|
|
||||||
return ownBLZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBIC() {
|
public String getOwnBIC() {
|
||||||
return ownBIC;
|
return ownBIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnBankName() {
|
|
||||||
return ownBankName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnIBAN() {
|
public String getOwnIBAN() {
|
||||||
return ownIBAN;
|
return ownIBAN;
|
||||||
|
|||||||
@@ -38,26 +38,11 @@ public abstract class MustangReaderTestCase extends TestCase implements IExporta
|
|||||||
|
|
||||||
protected class Payment implements IZUGFeRDTradeSettlementPayment {
|
protected class Payment implements IZUGFeRDTradeSettlementPayment {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnKto() {
|
|
||||||
return "44421800";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnBLZ() {
|
|
||||||
return "41441604";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBIC() {
|
public String getOwnBIC() {
|
||||||
return "COBADEFFXXX";
|
return "COBADEFFXXX";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnBankName() {
|
|
||||||
return "Commerzbank";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnPaymentInfoText() {
|
public String getOwnPaymentInfoText() {
|
||||||
return "Überweisung";
|
return "Überweisung";
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import junit.framework.TestSuite;
|
|||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -203,7 +204,7 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase {
|
|||||||
try (InputStream SOURCE_PDF =
|
try (InputStream SOURCE_PDF =
|
||||||
this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
||||||
) {
|
) {
|
||||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA3()
|
ZUGFeRDExporterFromA3 ze = new ZUGFeRDExporterFromA3()
|
||||||
.setProducer("My Application")
|
.setProducer("My Application")
|
||||||
.setCreator(System.getProperty("user.name"))
|
.setCreator(System.getProperty("user.name"))
|
||||||
.setZUGFeRDVersion(1)
|
.setZUGFeRDVersion(1)
|
||||||
|
|||||||
@@ -430,7 +430,16 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
|||||||
try (InputStream SOURCE_PDF = this.getClass()
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
||||||
|
|
||||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||||
|
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = SOURCE_PDF.read(buffer)) != -1) {
|
||||||
|
result.write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
ze.addAdditionalFile("test.pdf", result.toByteArray());
|
||||||
|
|
||||||
ze.setTransaction(this);
|
ze.setTransaction(this);
|
||||||
ze.disableAutoClose(true);
|
ze.disableAutoClose(true);
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_PDF);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import junit.framework.TestCase;
|
|||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class ZF2PushTest extends TestCase {
|
public class ZF2PushTest extends TestCase {
|
||||||
final String TARGET_PDF = "./target/testout-ZF2Push.pdf";
|
final String TARGET_PDF = "./target/testout-ZF2Push.pdf";
|
||||||
|
final String TARGET_CORRECTIONPDF = "./target/testout-ZF2Correction.pdf";
|
||||||
|
|
||||||
public void testPushExport() {
|
public void testPushExport() {
|
||||||
|
|
||||||
@@ -53,7 +54,49 @@ public class ZF2PushTest extends TestCase {
|
|||||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0))));
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0))));
|
||||||
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
ze.export(TARGET_PDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check the contents (like MustangReaderTest)
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||||
|
|
||||||
|
assertTrue(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
assertEquals(amountStr, zi.getAmount());
|
||||||
|
assertEquals(zi.getHolder(), orgname);
|
||||||
|
assertEquals(zi.getForeignReference(), number);
|
||||||
|
try {
|
||||||
|
assertEquals(zi.getVersion(), 2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public void testAttachmentsExport() {
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String amountStr = "1.00";
|
||||||
|
BigDecimal amount = new BigDecimal(amountStr);
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||||
|
.set
|
||||||
|
);
|
||||||
|
ze.attachFile("one.pdf");
|
||||||
|
ze.attachFile("two.pdf");
|
||||||
String theXML = new String(ze.getProvider().getXML());
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_PDF);
|
||||||
@@ -76,6 +119,145 @@ public class ZF2PushTest extends TestCase {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testItemChargesAllowancesExport() {
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String amountStr = "1.00";
|
||||||
|
BigDecimal amount = new BigDecimal(amountStr);
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addCharge(new BigDecimal(0.1)))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new BigDecimal(0.07)))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new BigDecimal(0.07)).addCharge(new BigDecimal(0.1)))
|
||||||
|
|
||||||
|
);
|
||||||
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
ze.export(TARGET_PDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check the contents (like MustangReaderTest)
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||||
|
|
||||||
|
assertFalse(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
assertEquals(amountStr, zi.getAmount());
|
||||||
|
assertEquals(zi.getHolder(), orgname);
|
||||||
|
assertEquals(zi.getForeignReference(), number);
|
||||||
|
try {
|
||||||
|
assertEquals(zi.getVersion(), 2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testItemChargesAllowancesExport() {
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String amountStr = "1.00";
|
||||||
|
BigDecimal amount = new BigDecimal(amountStr);
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||||
|
.addCharge(new BigDecimal(0.5))
|
||||||
|
.addAllowance(new BigDecimal(0.7))
|
||||||
|
|
||||||
|
);
|
||||||
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
ze.export(TARGET_PDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check the contents (like MustangReaderTest)
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||||
|
|
||||||
|
assertFalse(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
assertEquals(amountStr, zi.getAmount());
|
||||||
|
assertEquals(zi.getHolder(), orgname);
|
||||||
|
assertEquals(zi.getForeignReference(), number);
|
||||||
|
try {
|
||||||
|
assertEquals(zi.getVersion(), 2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
public void testCorrectionExport() {
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String priceStr = "1.00";
|
||||||
|
BigDecimal price = new BigDecimal(priceStr);
|
||||||
|
BigDecimal amount=new BigDecimal(-1.0);
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), price, amount))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), price, amount))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), price, amount))
|
||||||
|
.setDocumentCode("384")
|
||||||
|
|
||||||
|
);
|
||||||
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
ze.export(TARGET_CORRECTIONPDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check the contents (like MustangReaderTest)
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_CORRECTIONPDF);
|
||||||
|
|
||||||
|
assertTrue(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
assertEquals("-3.00", zi.getAmount());
|
||||||
|
assertEquals(zi.getHolder(), orgname);
|
||||||
|
assertEquals(zi.getForeignReference(), number);
|
||||||
|
try {
|
||||||
|
assertEquals(zi.getVersion(), 2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user