updated user documentation (ZugferdDev), added developer documentation(MustangDev), added java sample file, added organisation information plaintext "REG" field, changed version numbers to 1.2.0
This commit is contained in:
BIN
mustang/doc/MustangDev.en.odt
Normal file
BIN
mustang/doc/MustangDev.en.odt
Normal file
Binary file not shown.
277
mustang/doc/MustangWriter.java
Normal file
277
mustang/doc/MustangWriter.java
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
package zugferd;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
private BigDecimal price, quantity;
|
||||||
|
|
||||||
|
public Item(BigDecimal price, BigDecimal quantity, Product product) {
|
||||||
|
super();
|
||||||
|
this.price = price;
|
||||||
|
this.quantity = quantity;
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Product product;
|
||||||
|
|
||||||
|
public BigDecimal getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(BigDecimal price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Product getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct(Product product) {
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Product implements IZUGFeRDExportableProduct {
|
||||||
|
private String description, name, unit;
|
||||||
|
|
||||||
|
public Product(String description, String name, String unit,
|
||||||
|
BigDecimal VATPercent) {
|
||||||
|
super();
|
||||||
|
this.description = description;
|
||||||
|
this.name = name;
|
||||||
|
this.unit = unit;
|
||||||
|
this.VATPercent = VATPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal VATPercent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getVATPercent() {
|
||||||
|
return VATPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVATPercent(BigDecimal vATPercent) {
|
||||||
|
VATPercent = vATPercent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MustangWriter implements IZUGFeRDExportableTransaction {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
MustangWriter w=new MustangWriter();
|
||||||
|
w.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getDeliveryDate() {
|
||||||
|
return new GregorianCalendar(2015, Calendar.OCTOBER, 7).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getDueDate() {
|
||||||
|
return new GregorianCalendar(2015, Calendar.OCTOBER, 29).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getIssueDate() {
|
||||||
|
return new GregorianCalendar(2015, Calendar.OCTOBER, 8).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNumber() {
|
||||||
|
return "RE-20151008/504";
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 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("1"), designProduct);
|
||||||
|
allItems[1] = new Item(new BigDecimal("0.79"),
|
||||||
|
new BigDecimal("400"), balloonProduct);
|
||||||
|
allItems[2] = new Item(new BigDecimal("0.10"),
|
||||||
|
new BigDecimal("200"), airProduct);
|
||||||
|
return allItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apply() {
|
||||||
|
PDDocument doc;
|
||||||
|
try {
|
||||||
|
System.out.println("Reading blank PDF");
|
||||||
|
doc = PDDocument
|
||||||
|
.load("/Users/jstaerk/workspace/zugferd/MustangGnuaccountingBeispielRE-20151008_504blanko.pdf");
|
||||||
|
ZUGFeRDExporter ze = new ZUGFeRDExporter();
|
||||||
|
System.out.println("Converting to PDF/A-3u");
|
||||||
|
ze.PDFmakeA3compliant(doc, "Mustangproject",
|
||||||
|
System.getProperty("user.name"), true);
|
||||||
|
System.out.println("Generating and attaching ZUGFeRD-Data");
|
||||||
|
ze.setTest();
|
||||||
|
ze.PDFattachZugferdFile(doc, this);
|
||||||
|
System.out.println("Writing ZUGFeRD-PDF");
|
||||||
|
|
||||||
|
doc.save("/Users/jstaerk/workspace/zugferd/MustangGnuaccountingBeispielRE-20151008_504.pdf");
|
||||||
|
System.out.println("Done.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (TransformerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (COSVisitorException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwnOrganisationFullPlaintextInfo() {
|
||||||
|
return "Bei Spiel GmbH\n"
|
||||||
|
+ "Ecke 12\n"
|
||||||
|
+ "12345 Stadthausen\n"
|
||||||
|
+ "Geschäftsführer: Max Mustermann";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||||
<artifactId>mustang</artifactId>
|
<artifactId>mustang</artifactId>
|
||||||
<version>1.1.3-SNAPSHOT</version>
|
<version>1.2.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Mustang</name>
|
<name>Mustang</name>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public interface IZUGFeRDExportableTransaction {
|
public interface IZUGFeRDExportableTransaction {
|
||||||
@@ -27,6 +26,19 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
*/
|
*/
|
||||||
Date getIssueDate();
|
Date getIssueDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this should be the full sender institution name, details, manager and tax registration like.
|
||||||
|
* It is one of the few functions which may return null.
|
||||||
|
*
|
||||||
|
Lieferant GmbH
|
||||||
|
Lieferantenstraße 20
|
||||||
|
80333 München
|
||||||
|
Deutschland
|
||||||
|
Geschäftsführer: Hans Muster
|
||||||
|
Handelsregisternummer: H A 123
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getOwnOrganisationFullPlaintextInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when the invoice is to be paid
|
* when the invoice is to be paid
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public class ZUGFeRDExporter {
|
|||||||
|
|
||||||
private class LineCalc {
|
private class LineCalc {
|
||||||
private IZUGFeRDExportableItem currentItem=null;
|
private IZUGFeRDExportableItem currentItem=null;
|
||||||
private BigDecimal priceGross;
|
|
||||||
private BigDecimal totalGross;
|
private BigDecimal totalGross;
|
||||||
private BigDecimal itemTotalNetAmount;
|
private BigDecimal itemTotalNetAmount;
|
||||||
private BigDecimal itemTotalVATAmount;
|
private BigDecimal itemTotalVATAmount;
|
||||||
@@ -74,17 +73,12 @@ public class ZUGFeRDExporter {
|
|||||||
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
||||||
this.currentItem=currentItem;
|
this.currentItem=currentItem;
|
||||||
BigDecimal multiplicator=currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
|
BigDecimal multiplicator=currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
|
||||||
priceGross=currentItem.getPrice().multiply(multiplicator);
|
// priceGross=currentItem.getPrice().multiply(multiplicator);
|
||||||
totalGross=currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
|
totalGross=currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
|
||||||
itemTotalNetAmount=currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
itemTotalNetAmount=currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
itemTotalVATAmount=totalGross.subtract(itemTotalNetAmount);
|
itemTotalVATAmount=totalGross.subtract(itemTotalNetAmount);
|
||||||
}
|
}
|
||||||
/* public BigDecimal getPriceGross() {
|
|
||||||
return priceGross;
|
|
||||||
}
|
|
||||||
public BigDecimal getTotalGross() {
|
|
||||||
return totalGross;
|
|
||||||
}*/
|
|
||||||
public BigDecimal getItemTotalNetAmount() {
|
public BigDecimal getItemTotalNetAmount() {
|
||||||
return itemTotalNetAmount;
|
return itemTotalNetAmount;
|
||||||
}
|
}
|
||||||
@@ -271,6 +265,17 @@ public class ZUGFeRDExporter {
|
|||||||
if (isTest) {
|
if (isTest) {
|
||||||
testBooleanStr="true";
|
testBooleanStr="true";
|
||||||
|
|
||||||
|
}
|
||||||
|
String senderReg="";
|
||||||
|
if (trans.getOwnOrganisationFullPlaintextInfo()!=null) {
|
||||||
|
senderReg=""
|
||||||
|
+ "<ram:IncludedNote>\n"
|
||||||
|
+ " <ram:Content>\n"
|
||||||
|
+ trans.getOwnOrganisationFullPlaintextInfo()
|
||||||
|
+ " </ram:Content>\n"
|
||||||
|
+ "<ram:SubjectCode>REG</ram:SubjectCode>\n"
|
||||||
|
+ "</ram:IncludedNote>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
@@ -289,6 +294,7 @@ public class ZUGFeRDExporter {
|
|||||||
+ " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
+ " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getIssueDate())+"</udt:DateTimeString></ram:IssueDateTime>\n" //date format was 20130605 //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getIssueDate())+"</udt:DateTimeString></ram:IssueDateTime>\n" //date format was 20130605 //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
+ senderReg
|
||||||
// + " <IncludedNote>\n"
|
// + " <IncludedNote>\n"
|
||||||
// + " <Content>\n"
|
// + " <Content>\n"
|
||||||
// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
|
// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user