added writer test
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,14 @@
|
|||||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||||
<artifactId>mustang</artifactId>
|
<artifactId>mustang</artifactId>
|
||||||
<version>1.1.0.alpha</version>
|
<version>1.1.0.alpha</version>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>apache-snapshot</id>
|
||||||
|
<url>http://repository.apache.org/content/groups/snapshots</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>mustang</name>
|
<name>mustang</name>
|
||||||
|
|||||||
BIN
mustang/src/test/MustangGnuaccountingBeispielRE-20140703_502.pdf
Normal file
BIN
mustang/src/test/MustangGnuaccountingBeispielRE-20140703_502.pdf
Normal file
Binary file not shown.
Binary file not shown.
@@ -9,14 +9,14 @@ import junit.framework.TestSuite;
|
|||||||
/**
|
/**
|
||||||
* Unit test for simple App.
|
* Unit test for simple App.
|
||||||
*/
|
*/
|
||||||
public class AppTest extends TestCase {
|
public class MustangReaderTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Create the test case
|
* Create the test case
|
||||||
*
|
*
|
||||||
* @param testName
|
* @param testName
|
||||||
* name of the test case
|
* name of the test case
|
||||||
*/
|
*/
|
||||||
public AppTest(String testName) {
|
public MustangReaderTest(String testName) {
|
||||||
super(testName);
|
super(testName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public class AppTest extends TestCase {
|
|||||||
* @return the suite of tests being tested
|
* @return the suite of tests being tested
|
||||||
*/
|
*/
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new TestSuite(AppTest.class);
|
return new TestSuite(MustangReaderTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +32,7 @@ public class AppTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testImport() {
|
public void testImport() {
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
zi.extract("./src/test/java/org/mustangproject/ZUGFeRD/RE-20140628_9.pdf");
|
zi.extract("./src/test/MustangGnuaccountingBeispielRE-20140703_502.pdf");
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
|
|
||||||
String amount=null;
|
String amount=null;
|
||||||
@@ -51,12 +51,13 @@ public class AppTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
assertEquals(amount, "1.19");
|
assertEquals(amount, "571.04");
|
||||||
assertEquals(bic, "DE5656565");
|
assertEquals(bic, "COBADEFXXX");
|
||||||
assertEquals(iban, "DE1234");
|
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
||||||
assertEquals(holder, "usegroup");
|
assertEquals(holder, "Bei Spiel GmbH");
|
||||||
assertEquals(ref, "RE-20140628/9");
|
assertEquals(ref, "RE-20140703/502");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,344 @@
|
|||||||
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.apache.pdfbox.exceptions.COSVisitorException;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTransaction;
|
||||||
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
|
||||||
|
|
||||||
|
|
||||||
|
public class MustangWriterTest extends TestCase implements IZUGFeRDExportableTransaction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getDeliveryDate() {
|
||||||
|
return new GregorianCalendar(2014, Calendar.JULY, 3).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getDueDate() {
|
||||||
|
return new GregorianCalendar(2014, Calendar.JULY, 24).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getIssueDate() {
|
||||||
|
return new GregorianCalendar(2014, Calendar.JULY, 3).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNumber() {
|
||||||
|
return "RE-20140703/502";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnBIC() {
|
||||||
|
return "COBADEFXXX";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnBankName() {
|
||||||
|
return "Commerzbank";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnCountry() {
|
||||||
|
return "DE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnIBAN() {
|
||||||
|
return "DE88 2008 0000 0970 3757 00";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnLocation() {
|
||||||
|
return "Stadthausen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnOrganisationName() {
|
||||||
|
return "Bei Spiel GmbH";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnStreet() {
|
||||||
|
return "Ecke 12";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnTaxID() {
|
||||||
|
return "22/815/0815/4";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnVATID() {
|
||||||
|
return "DE136695976";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnZIP() {
|
||||||
|
return "12345";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IZUGFeRDExportableContact getRecipient() {
|
||||||
|
return new Contact();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getTotal() {
|
||||||
|
return new BigDecimal("496.00");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getTotalGross() {
|
||||||
|
return new BigDecimal("571.04");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IZUGFeRDExportableItem[] getZFItems() {
|
||||||
|
Item[] allItems = new Item[3];
|
||||||
|
Product designProduct = new Product("",
|
||||||
|
"Künstlerische Gestaltung (Stunde)", "HUR", new BigDecimal(
|
||||||
|
"7.000000"));
|
||||||
|
Product balloonProduct = new Product("", "Luftballon", "C62",
|
||||||
|
new BigDecimal("19.000000"));
|
||||||
|
Product airProduct = new Product("", "Heiße Luft pro Liter", "LTR",
|
||||||
|
new BigDecimal("19.000000"));
|
||||||
|
|
||||||
|
allItems[0] = new Item(new BigDecimal("160"), new BigDecimal("171.20"),
|
||||||
|
new BigDecimal("1"), new BigDecimal("171.20"), designProduct);
|
||||||
|
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("0.94"),
|
||||||
|
new BigDecimal("400"), new BigDecimal("376.04"), balloonProduct);
|
||||||
|
allItems[2] = new Item(new BigDecimal("0.10"), new BigDecimal("0.12"),
|
||||||
|
new BigDecimal("200"), new BigDecimal("23.80"), airProduct);
|
||||||
|
return allItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Contact implements IZUGFeRDExportableContact {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCountry() {
|
||||||
|
return "DE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLocation() {
|
||||||
|
return "Spielkreis";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Theodor Est";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStreet() {
|
||||||
|
return "Bahnstr. 42";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVATID() {
|
||||||
|
return "DE999999999";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getZIP() {
|
||||||
|
return "88802";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Item implements IZUGFeRDExportableItem {
|
||||||
|
|
||||||
|
public Item(BigDecimal price, BigDecimal priceGross,
|
||||||
|
BigDecimal quantity, BigDecimal totalGross, Product product) {
|
||||||
|
super();
|
||||||
|
this.price = price;
|
||||||
|
this.priceGross = priceGross;
|
||||||
|
this.quantity = quantity;
|
||||||
|
this.totalGross = totalGross;
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal price, priceGross, quantity, totalGross;
|
||||||
|
private Product product;
|
||||||
|
|
||||||
|
public BigDecimal getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(BigDecimal price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPriceGross() {
|
||||||
|
return priceGross;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriceGross(BigDecimal priceGross) {
|
||||||
|
this.priceGross = priceGross;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalGross() {
|
||||||
|
return totalGross;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalGross(BigDecimal totalGross) {
|
||||||
|
this.totalGross = totalGross;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Product getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct(Product product) {
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Product implements IZUGFeRDExportableProduct {
|
||||||
|
private String description, name, unit;
|
||||||
|
private BigDecimal VATPercent;
|
||||||
|
|
||||||
|
public Product(String description, String name, String unit,
|
||||||
|
BigDecimal VATPercent) {
|
||||||
|
super();
|
||||||
|
this.description = description;
|
||||||
|
this.name = name;
|
||||||
|
this.unit = unit;
|
||||||
|
this.VATPercent = VATPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getVATPercent() {
|
||||||
|
return VATPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVATPercent(BigDecimal vATPercent) {
|
||||||
|
VATPercent = vATPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apply() {
|
||||||
|
PDDocument doc;
|
||||||
|
try {
|
||||||
|
System.out.println("Lese Blanko-PDF");
|
||||||
|
doc = PDDocument
|
||||||
|
.load("./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf");
|
||||||
|
// automatically add Zugferd to all outgoing invoices
|
||||||
|
ZUGFeRDExporter ze = new ZUGFeRDExporter();
|
||||||
|
System.out.println("Wandle in PDF/A-3u um");
|
||||||
|
ze.PDFmakeA3compliant(doc, "My Application",
|
||||||
|
System.getProperty("user.name"), true);
|
||||||
|
System.out.println("ZUGFeRD-Daten generieren und anhängen");
|
||||||
|
ze.PDFattachZugferdFile(doc, this);
|
||||||
|
System.out.println("Schreibe ZUGFeRD-PDF");
|
||||||
|
doc.save("./src/test/MustangGnuaccountingBeispielRE-20140703_502new.pdf");
|
||||||
|
System.out.println("Fertig.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (TransformerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (COSVisitorException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the test case
|
||||||
|
*
|
||||||
|
* @param testName
|
||||||
|
* name of the test case
|
||||||
|
*/
|
||||||
|
public MustangWriterTest(String testName) {
|
||||||
|
super(testName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
|
*/
|
||||||
|
public static Test suite() {
|
||||||
|
return new TestSuite(MustangWriterTest.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void testExport() {
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
|
zi.extract("./src/test/MustangGnuaccountingBeispielRE-20140703_502new.pdf");
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
|
||||||
|
String amount=null;
|
||||||
|
String bic=null;
|
||||||
|
String iban=null;
|
||||||
|
String holder=null;
|
||||||
|
String ref=null;
|
||||||
|
|
||||||
|
if (zi.canParse()) {
|
||||||
|
zi.parse();
|
||||||
|
amount=zi.getAmount();
|
||||||
|
bic=zi.getBIC();
|
||||||
|
iban=zi.getIBAN();
|
||||||
|
holder=zi.getHolder();
|
||||||
|
ref=zi.getForeignReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(amount, "571.04");
|
||||||
|
assertEquals(bic, "COBADEFXXX");
|
||||||
|
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
||||||
|
assertEquals(holder, "Bei Spiel GmbH");
|
||||||
|
assertEquals(ref, "RE-20140703/502");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Wed Jun 25 21:50:56 CEST 2014
|
#Sat Jun 28 19:58:49 CEST 2014
|
||||||
version=1.0.2
|
version=1.1.0.alpha
|
||||||
groupId=org.mustangproject.ZUGFeRD
|
groupId=org.mustangproject.ZUGFeRD
|
||||||
artifactId=mustang
|
artifactId=mustang
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<testsuite failures="0" time="0.011" errors="0" skipped="0" tests="1" name="org.mustangproject.ZUGFeRD.AppTest">
|
<testsuite failures="0" time="0.224" errors="0" skipped="0" tests="1" name="org.mustangproject.ZUGFeRD.AppTest">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
||||||
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64"/>
|
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64"/>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<property name="java.specification.name" value="Java Platform API Specification"/>
|
<property name="java.specification.name" value="Java Platform API Specification"/>
|
||||||
<property name="java.class.version" value="50.0"/>
|
<property name="java.class.version" value="50.0"/>
|
||||||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
||||||
<property name="os.version" value="3.5.0-51-generic"/>
|
<property name="os.version" value="3.5.0-52-generic"/>
|
||||||
<property name="user.home" value="/home/jstaerk"/>
|
<property name="user.home" value="/home/jstaerk"/>
|
||||||
<property name="user.timezone" value="Europe/Berlin"/>
|
<property name="user.timezone" value="Europe/Berlin"/>
|
||||||
<property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
|
<property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<property name="java.vm.specification.version" value="1.0"/>
|
<property name="java.vm.specification.version" value="1.0"/>
|
||||||
<property name="sun.arch.data.model" value="64"/>
|
<property name="sun.arch.data.model" value="64"/>
|
||||||
<property name="java.home" value="/usr/lib/jvm/java-6-openjdk-amd64/jre"/>
|
<property name="java.home" value="/usr/lib/jvm/java-6-openjdk-amd64/jre"/>
|
||||||
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher "package""/>
|
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher "test""/>
|
||||||
<property name="java.specification.vendor" value="Sun Microsystems Inc."/>
|
<property name="java.specification.vendor" value="Sun Microsystems Inc."/>
|
||||||
<property name="user.language" value="de"/>
|
<property name="user.language" value="de"/>
|
||||||
<property name="java.vm.info" value="mixed mode"/>
|
<property name="java.vm.info" value="mixed mode"/>
|
||||||
@@ -56,5 +56,5 @@
|
|||||||
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
||||||
<property name="sun.cpu.isalist" value=""/>
|
<property name="sun.cpu.isalist" value=""/>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase time="0.001" classname="org.mustangproject.ZUGFeRD.AppTest" name="testApp"/>
|
<testcase time="0.213" classname="org.mustangproject.ZUGFeRD.AppTest" name="testImport"/>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Test set: org.mustangproject.ZUGFeRD.AppTest
|
Test set: org.mustangproject.ZUGFeRD.AppTest
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 sec
|
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.223 sec
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user