moving tax id and vat id into tradeparty
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class Invoice implements IExportableTransaction {
|
public class Invoice implements IExportableTransaction {
|
||||||
|
|
||||||
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownTaxID = null, ownVATID = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
||||||
protected Date issueDate = null, dueDate = null, deliveryDate = null;
|
protected Date issueDate = null, dueDate = null, deliveryDate = null;
|
||||||
protected BigDecimal totalPrepaidAmount = null;
|
protected BigDecimal totalPrepaidAmount = null;
|
||||||
protected TradeParty sender=null, recipient = null, deliveryAddress = null;
|
protected TradeParty sender=null, recipient = null, deliveryAddress = null;
|
||||||
@@ -81,6 +81,16 @@ public class Invoice implements IExportableTransaction {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* switch type to invoice correction and refer to document number
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Invoice setCorrection(String number) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnOrganisationFullPlaintextInfo() {
|
public String getOwnOrganisationFullPlaintextInfo() {
|
||||||
return ownOrganisationFullPlaintextInfo;
|
return ownOrganisationFullPlaintextInfo;
|
||||||
@@ -183,21 +193,21 @@ public class Invoice implements IExportableTransaction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnTaxID() {
|
public String getOwnTaxID() {
|
||||||
return ownTaxID;
|
return getSender().getTaxID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Invoice setOwnTaxID(String ownTaxID) {
|
public Invoice setOwnTaxID(String ownTaxID) {
|
||||||
this.ownTaxID = ownTaxID;
|
sender.addTaxID(ownTaxID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnVATID() {
|
public String getOwnVATID() {
|
||||||
return ownVATID;
|
return getSender().getVATID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Invoice setOwnVATID(String ownVATID) {
|
public Invoice setOwnVATID(String ownVATID) {
|
||||||
this.ownVATID = ownVATID;
|
sender.addVATID(ownVATID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +411,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return (dueDate != null) && (sender != null) && (ownTaxID != null) && (ownVATID != null) && (recipient != null);
|
return (dueDate != null) && (sender != null) && (sender.getTaxID() != null) && (sender.getVATID() != null) && (recipient != null);
|
||||||
//contact
|
//contact
|
||||||
// this.phone = phone;
|
// this.phone = phone;
|
||||||
// this.email = email;
|
// this.email = email;
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* *********************************************************************
|
|
||||||
* <p>
|
|
||||||
* Copyright 2018 Jochen Staerk
|
|
||||||
* <p>
|
|
||||||
* Use is subject to license terms.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* <p>
|
|
||||||
* **********************************************************************
|
|
||||||
*/
|
|
||||||
package org.mustangproject;
|
|
||||||
|
|
||||||
import org.mustangproject.ZUGFeRD.*;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class InvoiceCorrection extends Invoice {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTradeParty;
|
|||||||
public class TradeParty implements IZUGFeRDExportableTradeParty {
|
public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||||
|
|
||||||
protected String name,zip,street,location,country;
|
protected String name,zip,street,location,country;
|
||||||
|
protected String taxID=null, vatID=null;
|
||||||
protected Contact contact=null;
|
protected Contact contact=null;
|
||||||
|
|
||||||
public TradeParty(String name, String street, String zip, String location, String country) {
|
public TradeParty(String name, String street, String zip, String location, String country) {
|
||||||
@@ -22,6 +23,26 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TradeParty addTaxID(String taxID) {
|
||||||
|
this.taxID=taxID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TradeParty addVATID(String vatID) {
|
||||||
|
this.vatID=vatID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVATID() {
|
||||||
|
return vatID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTaxID() {
|
||||||
|
return taxID;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,11 @@ public interface IExportableTransaction {
|
|||||||
* @return Tax ID (not VAT ID) of the sender
|
* @return Tax ID (not VAT ID) of the sender
|
||||||
*/
|
*/
|
||||||
default String getOwnTaxID() {
|
default String getOwnTaxID() {
|
||||||
return null;
|
if (getSender()!=null) {
|
||||||
|
return getSender().getTaxID();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +179,11 @@ public interface IExportableTransaction {
|
|||||||
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
||||||
*/
|
*/
|
||||||
default String getOwnVATID() {
|
default String getOwnVATID() {
|
||||||
return null;
|
if (getSender()!=null) {
|
||||||
|
return getSender().getVATID();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import org.mustangproject.TradeParty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation neccessary interface for ZUGFeRD exporter Licensed under the APLv2
|
* Mustangproject's ZUGFeRD implementation neccessary interface for ZUGFeRD exporter Licensed under the APLv2
|
||||||
*
|
*
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* @version 1.2.0
|
* @version 2.0.0
|
||||||
* dated 2014-05-10
|
* dated 2020-09-12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -127,4 +129,14 @@ public interface IZUGFeRDExportableTradeParty {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* obligatory for sender but not for recipient
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default String getTaxID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public abstract class MustangReaderTestCase extends TestCase implements IExporta
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected class SenderTradeParty implements IZUGFeRDExportableTradeParty {
|
protected class SenderTradeParty implements IZUGFeRDExportableTradeParty {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -136,6 +136,11 @@ public abstract class MustangReaderTestCase extends TestCase implements IExporta
|
|||||||
return "Ecke 12";
|
return "Ecke 12";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTaxID() {
|
||||||
|
return "0815";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Item implements IZUGFeRDExportableItem {
|
protected class Item implements IZUGFeRDExportableItem {
|
||||||
|
|||||||
@@ -77,47 +77,6 @@ public class ZF2PushTest extends TestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testInvoiceCorrectionExport() {
|
|
||||||
|
|
||||||
// the writing part
|
|
||||||
|
|
||||||
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 InvoiceCorrection().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setContractReferencedDocument("0815").setSender(new TradeParty(orgname, "teststr","55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new TradeParty("Franz Müller", "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"));
|
|
||||||
assertTrue(zi.getUTF8().contains("0815"));
|
|
||||||
|
|
||||||
// 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() {
|
public void testAttachmentsExport() {
|
||||||
|
|
||||||
String orgname = "Test company";
|
String orgname = "Test company";
|
||||||
@@ -131,7 +90,7 @@ 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()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setContact(new Contact("Franz Müller","01779999999", "franz@mueller.de", "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()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE").addTaxID("0815")).setOwnVATID("0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("4711").setContact(new Contact("Franz Müller","01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||||
|
|
||||||
);
|
);
|
||||||
byte[] b={12,13};
|
byte[] b={12,13};
|
||||||
@@ -267,13 +226,12 @@ 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()).setOccurrencePeriod(new Date(),new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
Invoice i=new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setOccurrencePeriod(new Date(),new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE").addTaxID("4711").addVATID("0815")).setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("0815")).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))
|
.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)).setCorrection("0815");
|
||||||
.setDocumentCode("384")
|
System.err.println("deb "+i.getOwnTaxID());
|
||||||
|
ze.setTransaction(i);
|
||||||
);
|
|
||||||
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_CORRECTIONPDF);
|
ze.export(TARGET_CORRECTIONPDF);
|
||||||
|
|||||||
Reference in New Issue
Block a user