diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IProfileProvider.java b/src/main/java/org/mustangproject/ZUGFeRD/IProfileProvider.java
new file mode 100644
index 00000000..adc695df
--- /dev/null
+++ b/src/main/java/org/mustangproject/ZUGFeRD/IProfileProvider.java
@@ -0,0 +1,25 @@
+/** **********************************************************************
+ *
+ * Copyright 2018 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;
+
+public interface IProfileProvider {
+
+ public String getProfile();
+
+}
diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java
index 125852c8..7b7e1c89 100644
--- a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java
+++ b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java
@@ -46,13 +46,23 @@ public interface IZUGFeRDExportableContact {
*/
String getName();
+ default String getPhone() {
+ return null;
+ }
+
+ default String getEMail() {
+ return null;
+ }
+
/**
* Postal code of the recipient
*
* @return Postal code of the recipient
*/
- String getZIP();
+ default String getZIP() {
+ return null;
+ }
/**
@@ -60,7 +70,9 @@ public interface IZUGFeRDExportableContact {
*
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
*/
- String getVATID();
+ default String getVATID() {
+ return null;
+ }
/**
@@ -68,7 +80,9 @@ public interface IZUGFeRDExportableContact {
*
* @return two-letter iso country code of the contact
*/
- String getCountry();
+ default String getCountry() {
+ return null;
+ }
/**
@@ -76,7 +90,9 @@ public interface IZUGFeRDExportableContact {
*
* @return Returns the city of the recipient
*/
- String getLocation();
+ default String getLocation() {
+ return null;
+ }
/**
@@ -84,6 +100,8 @@ public interface IZUGFeRDExportableContact {
*
* @return street address (street+number) of the contact
*/
- String getStreet();
+ default String getStreet() {
+ return null;
+ }
}
diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java
index 112080ec..6addf89f 100644
--- a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java
+++ b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java
@@ -83,6 +83,15 @@ public interface IZUGFeRDExportableTransaction {
return null;
}
+ /**
+ * who processed the order
+ *
+ * @return the contact person at the supplier side
+ */
+ default IZUGFeRDExportableContact getOwnContact() {
+ return null;
+ }
+
IZUGFeRDAllowanceCharge[] getZFAllowances();
diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
index f898ad0f..a1d4a842 100644
--- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
+++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
@@ -26,7 +26,7 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
-public class ZUGFeRD2PullProvider implements IXMLProvider {
+public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
private class LineCalc {
private BigDecimal totalGross;
@@ -34,10 +34,12 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
private BigDecimal itemTotalVATAmount;
public LineCalc(IZUGFeRDExportableItem currentItem) {
- BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
-// priceGross=currentItem.getPrice().multiply(multiplicator);
+ BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100))
+ .add(new BigDecimal(1));
+ // priceGross=currentItem.getPrice().multiply(multiplicator);
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);
}
@@ -51,7 +53,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
-
//// MAIN CLASS
protected byte[] zugferdData;
@@ -60,23 +61,23 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
/**
* enables the flag to indicate a test invoice in the XML structure
*/
- public void setTest() {}
+ public void setTest() {
+ }
private String nDigitFormat(BigDecimal value, int scale) {
/*
* I needed 123,45, locale independent.I tried
- * NumberFormat.getCurrencyInstance().format( 12345.6789 ); but that is
- * locale specific.I also tried DecimalFormat df = new DecimalFormat(
- * "0,00" ); df.setDecimalSeparatorAlwaysShown(true);
- * df.setGroupingUsed(false); DecimalFormatSymbols symbols = new
- * DecimalFormatSymbols(); symbols.setDecimalSeparator(',');
- * symbols.setGroupingSeparator(' ');
+ * NumberFormat.getCurrencyInstance().format( 12345.6789 ); but that is locale
+ * specific.I also tried DecimalFormat df = new DecimalFormat( "0,00" );
+ * df.setDecimalSeparatorAlwaysShown(true); df.setGroupingUsed(false);
+ * DecimalFormatSymbols symbols = new DecimalFormatSymbols();
+ * symbols.setDecimalSeparator(','); symbols.setGroupingSeparator(' ');
* df.setDecimalFormatSymbols(symbols);
*
- * but that would not switch off grouping. Although I liked very much
- * the (incomplete) "BNF diagram" in
- * http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html
- * in the end I decided to calculate myself and take eur+sparator+cents
+ * but that would not switch off grouping. Although I liked very much the
+ * (incomplete) "BNF diagram" in
+ * http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html in the
+ * end I decided to calculate myself and take eur+sparator+cents
*
* This function will cut off, i.e. floor() subcent values Tests:
* System.err.println(utils.currencyFormat(new BigDecimal(0),
@@ -89,7 +90,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
*
* results 0.00 -1,10 -1,10 -1,01 20000123,34 20000123,34 12,00
*/
- value = value.setScale(scale, BigDecimal.ROUND_HALF_UP); // first, round so that e.g. 1.189999999999999946709294817992486059665679931640625 becomes 1.19
+ value = value.setScale(scale, BigDecimal.ROUND_HALF_UP); // first, round so that e.g.
+ // 1.189999999999999946709294817992486059665679931640625
+ // becomes 1.19
char[] repeat = new char[scale];
Arrays.fill(repeat, '0');
@@ -142,10 +145,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
/**
- * which taxes have been used with which amounts in this transaction,
- * empty for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable
- * to 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT)
- * 190 Eur
+ * which taxes have been used with which amounts in this transaction, empty for
+ * no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable to 19% VAT
+ * (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT) 190 Eur
*
* @return which taxes have been used with which amounts in this invoice
*/
@@ -155,7 +157,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
BigDecimal percent = currentItem.getProduct().getVATPercent();
LineCalc lc = new LineCalc(currentItem);
- VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(), trans.getDocumentCode());
+ VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
+ trans.getDocumentCode());
VATAmount current = hm.get(percent);
if (current == null) {
hm.put(percent, itemVATAmount);
@@ -166,6 +169,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
return hm;
}
+ public String getProfile() {
+ return "urn:cen.eu:en16931:2017";
+ }
@Override
public void generateXML(IZUGFeRDExportableTransaction trans) {
@@ -174,47 +180,50 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
String senderReg = "";
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
- senderReg = ""
- + "\n"
- + " \n"
- + trans.getOwnOrganisationFullPlaintextInfo()
- + " \n"
- + "REG\n"
- + "\n";
+ senderReg = "" + "\n" + " \n"
+ + trans.getOwnOrganisationFullPlaintextInfo() + " \n"
+ + "REG\n" + "\n";
}
-
String xml = "\n" //$NON-NLS-1$
+ "\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
-// + " "+testBooleanStr+"\n" //$NON-NLS-1$
+ // + "
+ // "+testBooleanStr+"\n"
+ // //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " urn:cen.eu:en16931:2017\n" //$NON-NLS-1$
+ + " " + getProfile() + "\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " " + trans.getNumber() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
-// + " RECHNUNG\n" //$NON-NLS-1$
+ // + " RECHNUNG\n" //$NON-NLS-1$
+ " 380\n" //$NON-NLS-1$
- + " " + zugferdDateFormat.format(trans.getIssueDate()) + "\n" //date format was 20130605 //$NON-NLS-1$ //$NON-NLS-2$
+ + " " //$NON-NLS-1$
+ + zugferdDateFormat.format(trans.getIssueDate()) + "\n" // date //$NON-NLS-1$
+ // format
+ // was
+ // 20130605
+ senderReg
-// + " \n"
-// + " \n"
-// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
-// + "\n"
-// + " \n"
-// + " \n"
-// + " \n"
-// + " \n"
-// + "Es bestehen Rabatt- und Bonusvereinbarungen.\n"
-// + " \n"
-// + " AAK\n"
-// + " \n"
+ // + " \n"
+ // + " \n"
+ // + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
+ // + "\n"
+ // + " \n"
+ // + " \n"
+ // + " \n"
+ // + " \n"
+ // + "Es bestehen Rabatt- und Bonusvereinbarungen.\n"
+ // + " \n"
+ // + " AAK\n"
+ // + " \n"
+ " \n" //$NON-NLS-1$
+ " \n"; //$NON-NLS-1$
int lineID = 0;
@@ -227,58 +236,86 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " " + lineID + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
-// + " 4012345001235\n"
-// + " KR3M\n"
-// + " 55T01\n"
+ // + " 4012345001235\n"
+ // + " KR3M\n"
+ // + " 55T01\n"
+ " " + currentItem.getProduct().getName() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " " + currentItem.getProduct().getDescription() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " " + currentItem.getProduct().getDescription() //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " " + priceFormat(currentItem.getPrice()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
- + " 1.0000\n" //$NON-NLS-1$ //$NON-NLS-2$
-// + " \n"
-// + " false\n"
-// + " 0.6667\n"
-// + " Rabatt\n"
-// + " \n"
+ + " " + priceFormat(currentItem.getPrice()) //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$ //currencyID=\"EUR\"
+ + " 1.0000\n" //$NON-NLS-1$
+ // + " \n"
+ // + " false\n"
+ // + " 0.6667\n"
+ // + " Rabatt\n"
+ // + " \n"
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " " + priceFormat(currentItem.getPrice()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
- + " 1.0000\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " " + priceFormat(currentItem.getPrice()) //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$ // currencyID=\"EUR\"
+ + " 1.0000\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " " + quantityFormat(currentItem.getQuantity()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " " //$NON-NLS-1$ //$NON-NLS-2$
+ + quantityFormat(currentItem.getQuantity()) + "\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " VAT\n" //$NON-NLS-1$
+ " S\n" //$NON-NLS-1$
- + " " + vatFormat(currentItem.getProduct().getVATPercent()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " " //$NON-NLS-1$
+ + vatFormat(currentItem.getProduct().getVATPercent()) + "\n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " " + currencyFormat(lc.getItemTotalNetAmount()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
+ + " " + currencyFormat(lc.getItemTotalNetAmount()) //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$ // currencyID=\"EUR\"
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n"; //$NON-NLS-1$
+ }
+
+ xml = xml + " \n"; //$NON-NLS-1$
+ if (trans.getReferenceNumber() != null) {
+ xml = xml + " " + trans.getReferenceNumber() + "\n";
+
+ }
+ xml = xml + " \n" //$NON-NLS-1$
+ // + " 4000001123452\n"
+ + " " + trans.getOwnOrganisationName() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (trans.getOwnContact() != null) {
+ xml = xml + "\n" + " " + trans.getOwnContact().getName()
+ + "\n";
+ if (trans.getOwnContact().getPhone() != null) {
+
+ xml = xml + " \n" + " "
+ + trans.getOwnContact().getPhone() + "\n"
+ + " \n";
+ }
+ if (trans.getOwnContact().getEMail() != null) {
+
+ xml = xml + " \n" + " "
+ + trans.getOwnContact().getEMail() + "\n"
+ + " \n";
+ }
+ xml = xml + " ";
}
- xml = xml + " \n" //$NON-NLS-1$
-// + " AB-312\n"
- + " \n" //$NON-NLS-1$
-// + " 4000001123452\n"
- + " " + trans.getOwnOrganisationName() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " \n"
- + " " + trans.getOwnZIP() + "\n"
- + " " + trans.getOwnStreet() + "\n"
- + " " + trans.getOwnLocation() + "\n"
- + " " + trans.getOwnCountry() + "\n"
- + " \n"
+ xml = xml + " \n" + " "
+ + trans.getOwnZIP() + "\n" + " "
+ + trans.getOwnStreet() + "\n" + " " + trans.getOwnLocation()
+ + "\n" + " " + trans.getOwnCountry()
+ + "\n" + " \n"
+ " \n" //$NON-NLS-1$
+ " " + trans.getOwnTaxID() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " \n" //$NON-NLS-1$
@@ -287,12 +324,12 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
-// + " GE2020211\n"
-// + " 4000001987658\n"
+ // + " GE2020211\n"
+ // + " 4000001987658\n"
+ " " + trans.getRecipient().getName() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
-// + " \n"
-// + " xxx\n"
-// + " \n"
+ // + " \n"
+ // + " xxx\n"
+ // + " \n"
+ " \n" //$NON-NLS-1$
+ " " + trans.getRecipient().getZIP() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " " + trans.getRecipient().getStreet() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
@@ -303,114 +340,127 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " " + trans.getRecipient().getVATID() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
-// + " \n"
-// + " 20130301\n"
-// + " 2013-471331\n"
-// + " \n"
+ // + " \n"
+ // + " 20130301\n"
+ // + " 2013-471331\n"
+ // + " \n"
+ " \n" //$NON-NLS-1$
- + " \n"
- + " \n"
- + " " + zugferdDateFormat.format(trans.getDeliveryDate()) + "\n"
+ + " \n" + " \n"
+ + " "
+ + zugferdDateFormat.format(trans.getDeliveryDate()) + "\n"
+ " \n"
- /*
- + " \n"
- + " 20130603\n"
- + " 2013-51112\n"
- + " \n" */
- + " \n"
- + " \n" //$NON-NLS-1$
+ /*
+ * + " \n" +
+ * " 20130603\n" +
+ * " 2013-51112\n" +
+ * " \n"
+ */
+ + " \n" + " \n" //$NON-NLS-2$
+ " " + trans.getNumber() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " EUR\n"; //$NON-NLS-1$
- for(IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
- xml += " \n" //$NON-NLS-1$
- + " 42\n" //$NON-NLS-1$
- + " Überweisung\n" //$NON-NLS-1$
- + " \n" //$NON-NLS-1$
- + " " + payment.getOwnIBAN() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " " + payment.getOwnKto() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " \n" //$NON-NLS-1$
- + " \n" //$NON-NLS-1$
- + " " + payment.getOwnBIC() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " " + payment.getOwnBLZ() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
-// + " "+trans.getOwnBankName()+"\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " \n" //$NON-NLS-1$
- + " \n"; //$NON-NLS-1$
- }
+ for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
+ xml += " \n" //$NON-NLS-1$
+ + " 42\n" //$NON-NLS-1$
+ + " Überweisung\n" //$NON-NLS-1$
+ + " \n" //$NON-NLS-1$
+ + " " + payment.getOwnIBAN() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " " + payment.getOwnKto() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " \n" //$NON-NLS-1$
+ + " \n" //$NON-NLS-1$
+ + " " + payment.getOwnBIC() + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " " + payment.getOwnBLZ() //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$
+ // + " "+trans.getOwnBankName()+"\n" //$NON-NLS-1$
+ // //$NON-NLS-2$
+ + " \n" //$NON-NLS-1$
+ + " \n"; //$NON-NLS-1$
+ }
HashMap VATPercentAmountMap = getVATPercentAmountMap();
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
if (amount != null) {
xml += " \n" //$NON-NLS-1$
- + " " + currencyFormat(amount.getCalculated()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
+ + " " + currencyFormat(amount.getCalculated()) //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$ //currencyID=\"EUR\"
+ " VAT\n" //$NON-NLS-1$
+ " " + currencyFormat(amount.getBasis()) + "\n" // currencyID=\"EUR\"
+ " S\n" //$NON-NLS-1$
- + " " + vatFormat(currentTaxPercent) + "\n" //$NON-NLS-1$
- + " \n"; //$NON-NLS-1$
-
+ + " " + vatFormat(currentTaxPercent) //$NON-NLS-1$
+ + "\n" + " \n"; //$NON-NLS-2$
}
}
- /* xml+= "
- + " \n"
- + " false\n"
- + " 10\n"
- + " 1.00\n"
- + " Sondernachlass\n"
- + " \n"
- + " VAT\n"
- + " S\n"
- + " 19\n"
- + " \n"
- + " \n"
- + " \n"
- + " false\n"
- + " 137.30\n"
- + " 13.73\n"
- + " Sondernachlass\n"
- + " \n"
- + " VAT\n"
- + " S\n"
- + " 7\n"
- + " \n"
- + " \n"
- + " \n"
- + " Versandkosten\n"
- + " 5.80\n"
- + " \n"
- + " VAT\n"
- + " S\n"
- + " 7\n"
- + " \n"
- + " \n"*/
+ /*
+ * xml+= " + " \n" +
+ * " false\n" +
+ * " 10\n" +
+ * " 1.00\n" +
+ * " Sondernachlass\n" +
+ * " \n" +
+ * " VAT\n" +
+ * " S\n" +
+ * " 19\n" +
+ * " \n" +
+ * " \n" +
+ * " \n" +
+ * " false\n" +
+ * " 137.30\n" +
+ * " 13.73\n" +
+ * " Sondernachlass\n" +
+ * " \n" +
+ * " VAT\n" +
+ * " S\n" +
+ * " 7\n" +
+ * " \n" +
+ * " \n" +
+ * " \n" +
+ * " Versandkosten\n" +
+ * " 5.80\n" +
+ * " \n" +
+ * " VAT\n" +
+ * " S\n" +
+ * " 7\n" +
+ * " \n" +
+ * " \n"
+ */
xml = xml + " \n" //$NON-NLS-1$
- + " Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()) + "\n"
- + " " + zugferdDateFormat.format(trans.getDueDate()) + "\n"//20130704 //$NON-NLS-1$ //$NON-NLS-2$
+ + " Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate())
+ + "\n" + " " //$NON-NLS-2$
+ + zugferdDateFormat.format(trans.getDueDate()) + "\n"// 20130704 //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
+ " \n" //$NON-NLS-1$
- + " " + currencyFormat(getTotal()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ currencyID=\"EUR\"
- + " 0.00\n" //$NON-NLS-1$ currencyID=\"EUR\"
- + " 0.00\n" //$NON-NLS-1$ // currencyID=\"EUR\"
-// + " 5.80\n"
-// + " 14.73\n"
- + " " + currencyFormat(getTotal()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
- + " " + currencyFormat(getTotalGross().subtract(getTotal())) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
- + " " + currencyFormat(getTotalGross()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
-// + " 0.00\n"
- + " " + currencyFormat(getTotalGross()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
+ + " " + currencyFormat(getTotal()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ // currencyID=\"EUR\"
+ + " 0.00\n" //$NON-NLS-1$ currencyID=\"EUR\"
+ + " 0.00\n" //$NON-NLS-1$ //
+ // currencyID=\"EUR\"
+ // + " 5.80\n"
+ // + " 14.73\n"
+ + " " + currencyFormat(getTotal()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ // //
+ // currencyID=\"EUR\"
+ + " " //$NON-NLS-1$
+ + currencyFormat(getTotalGross().subtract(getTotal())) + "\n" //$NON-NLS-1$
+ + " " + currencyFormat(getTotalGross()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ // //
+ // currencyID=\"EUR\"
+ // + " 0.00\n"
+ + " " + currencyFormat(getTotalGross()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$
+ // //
+ // currencyID=\"EUR\"
+ " \n" //$NON-NLS-1$
+ " \n"; //$NON-NLS-1$
-// + " \n"
-// + " \n"
-// + " \n"
-// + " Wir erlauben uns Ihnen folgende Positionen aus der Lieferung Nr. 2013-51112 in Rechnung zu stellen:\n"
-// + " \n"
-// + " \n"
-// + " \n";
-
+ // + " \n"
+ // + " \n"
+ // + " \n"
+ // + " Wir erlauben uns Ihnen folgende Positionen aus der Lieferung Nr.
+ // 2013-51112 in Rechnung zu stellen:\n"
+ // + " \n"
+ // + " \n"
+ // + " \n";
xml = xml + " \n" //$NON-NLS-1$
+ ""; //$NON-NLS-1$
@@ -429,7 +479,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } //$NON-NLS-1$
+ } // $NON-NLS-1$
}
}
diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java
index 11cb05c9..b437067a 100644
--- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java
+++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java
@@ -216,6 +216,13 @@ public class ZUGFeRDImporter {
return extractString("//HeaderExchangedDocument/TypeCode");
}
+ /**
+ * @return the referred document
+ */
+ public String getReference() {
+ return extractString("//ApplicableHeaderTradeAgreement/BuyerReference");
+ }
+
/**
* @return the sender's bank's BLZ code
*/
diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java
index 57043b05..bf9877f0 100644
--- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java
+++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java
@@ -68,7 +68,7 @@ public abstract class MustangReaderTestCase extends TestCase implements IZUGFeRD
}
}
- protected class Contact implements IZUGFeRDExportableContact {
+ protected class RecipientContact implements IZUGFeRDExportableContact {
@Override
public String getCountry() {
@@ -101,6 +101,27 @@ public abstract class MustangReaderTestCase extends TestCase implements IZUGFeRD
}
}
+ protected class SenderContact implements IZUGFeRDExportableContact {
+
+
+
+ @Override
+ public String getName() {
+ return "Dieter Mara";
+ }
+
+ @Override
+ public String getPhone() {
+ return "++49(0)1771234567";
+ }
+
+ @Override
+ public String getEMail() {
+ return "Dieter@Mara.de";
+ }
+
+ }
+
protected class Item implements IZUGFeRDExportableItem {
public Item(BigDecimal price, BigDecimal quantity, Product product) {
diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java
index 1bb90beb..74dee7e6 100644
--- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java
+++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java
@@ -19,7 +19,6 @@
package org.mustangproject.ZUGFeRD;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -75,6 +74,13 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase {
return "Ecke 12";
}
+
+ @Override
+ public IZUGFeRDExportableContact getOwnContact() {
+ return new SenderContact();
+
+ }
+
@Override
public String getOwnTaxID() {
return "22/815/0815/4";
@@ -92,7 +98,7 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase {
@Override
public IZUGFeRDExportableContact getRecipient() {
- return new Contact();
+ return new RecipientContact();
}
@Override
@@ -141,7 +147,7 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase {
@Override
public String getReferenceNumber() {
- return null;
+ return "AB321";
}
/**
diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java
index fef3a66a..f58c444b 100644
--- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java
+++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java
@@ -19,7 +19,6 @@
package org.mustangproject.ZUGFeRD;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -92,7 +91,12 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
@Override
public IZUGFeRDExportableContact getRecipient() {
- return new Contact();
+ return new RecipientContact();
+ }
+
+ @Override
+ public IZUGFeRDExportableContact getOwnContact() {
+ return new SenderContact();
}
@Override
@@ -148,7 +152,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
@Override
public String getReferenceNumber() {
- return null;
+ return "AB32";
}
/**
@@ -334,6 +338,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
// Reading ZUGFeRD
assertEquals(zi.getAmount(), "571.04");
assertEquals(zi.getBIC(), getTradeSettlementPayment()[0].getOwnBIC());
+ assertEquals(zi.getReference(), getReferenceNumber());
assertEquals(zi.getIBAN(), getTradeSettlementPayment()[0].getOwnIBAN());
assertEquals(zi.getKTO(), getTradeSettlementPayment()[0].getOwnKto());
assertEquals(zi.getHolder(), getOwnOrganisationName());