closes #201
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2.0.3
|
||||||
|
=======
|
||||||
|
|
||||||
|
|
||||||
|
- #201 correct embedded files in XRechnung
|
||||||
|
|
||||||
2.0.2
|
2.0.2
|
||||||
=======
|
=======
|
||||||
2020-11-25
|
2020-11-25
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
||||||
protected ArrayList<String> notes = null;
|
protected ArrayList<String> notes = null;
|
||||||
protected String contractReferencedDocument = null;
|
protected String contractReferencedDocument = null;
|
||||||
|
protected ArrayList<FileAttachment> xmlEmbeddedFiles=null;
|
||||||
|
|
||||||
protected Date detailedDeliveryDateStart = null;
|
protected Date detailedDeliveryDateStart = null;
|
||||||
protected Date detailedDeliveryPeriodEnd = null;
|
protected Date detailedDeliveryPeriodEnd = null;
|
||||||
@@ -78,6 +79,22 @@ public class Invoice implements IExportableTransaction {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Invoice embedFileInXML(FileAttachment fa) {
|
||||||
|
if (xmlEmbeddedFiles == null) {
|
||||||
|
xmlEmbeddedFiles=new ArrayList<FileAttachment>();
|
||||||
|
}
|
||||||
|
xmlEmbeddedFiles.add(fa);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileAttachment[] getAdditionalReferencedDocuments() {
|
||||||
|
if (xmlEmbeddedFiles == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return xmlEmbeddedFiles.toArray(new FileAttachment[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNumber() {
|
public String getNumber() {
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
+ " <ram:TypeCode>916</ram:TypeCode>\n"
|
+ " <ram:TypeCode>916</ram:TypeCode>\n"
|
||||||
+ " <ram:Name>" + f.getDescription() + "</ram:Name>\n"
|
+ " <ram:Name>" + f.getDescription() + "</ram:Name>\n"
|
||||||
+ " <ram:AttachmentBinaryObject mimeCode=\"" + f.getMimetype() + "\"\n"
|
+ " <ram:AttachmentBinaryObject mimeCode=\"" + f.getMimetype() + "\"\n"
|
||||||
+ " filename=\"" + f.getFilename() + "\">" + documentContent + "\n"
|
+ " filename=\"" + f.getFilename() + "\">" + documentContent + "</ram:AttachmentBinaryObject>\n"
|
||||||
+ " </ram:AdditionalReferencedDocument>\n";
|
+ " </ram:AdditionalReferencedDocument>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import static org.xmlunit.assertj.XmlAssert.assertThat;
|
|||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class XRTest extends TestCase {
|
public class XRTest extends TestCase {
|
||||||
final String TARGET_XML = "./target/testout-XR.xml";
|
final String TARGET_XML = "./target/testout-XR.xml";
|
||||||
|
final String TARGET_EDGE_XML = "./target/testout-XR-Edge.xml";
|
||||||
public void testXRExport() {
|
public void testXRExport() {
|
||||||
|
|
||||||
// the writing part
|
// the writing part
|
||||||
@@ -76,5 +77,48 @@ public class XRTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void testXREdgeExport() {
|
||||||
|
|
||||||
|
// the writing part
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String amountStr = "1.00";
|
||||||
|
BigDecimal amount = new BigDecimal(amountStr);
|
||||||
|
byte[] b = {12, 13};
|
||||||
|
FileAttachment fe1=new FileAttachment("one.pdf", "application/pdf", "Alternative", b);
|
||||||
|
FileAttachment fe2=new FileAttachment("two.pdf", "application/pdf", "Alternative", b);
|
||||||
|
Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
|
||||||
|
.setSender(new TradeParty(orgname,"teststr","55232","teststadt","DE").addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test","+49123456789","test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890","COBADEFXXX")))
|
||||||
|
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE"))
|
||||||
|
.setReferenceNumber("991-01484-64")//leitweg-id
|
||||||
|
// not using any VAT, this is also a test of zero-rated goods:
|
||||||
|
.setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), amount, new BigDecimal(1.0)))
|
||||||
|
.embedFileInXML(fe1).embedFileInXML(fe2);
|
||||||
|
|
||||||
|
|
||||||
|
ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
|
||||||
|
|
||||||
|
zf2p.setProfile(Profiles.getByName("XRechnung"));
|
||||||
|
zf2p.generateXML(i);
|
||||||
|
String theXML = new String(zf2p.getXML());
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
assertThat(theXML).valueByXPath("count(//*[local-name()='IncludedSupplyChainTradeLineItem'])")
|
||||||
|
.asInt()
|
||||||
|
.isEqualTo(1); //2 errors are OK because there is a known bug
|
||||||
|
|
||||||
|
|
||||||
|
assertThat(theXML).valueByXPath("//*[local-name()='DuePayableAmount']")
|
||||||
|
.asDouble()
|
||||||
|
.isEqualTo(1);
|
||||||
|
try {
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(TARGET_EDGE_XML));
|
||||||
|
writer.write(theXML);
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ public class ZF2PushTest extends TestCase {
|
|||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
byte[] b = {12, 13};
|
byte[] b = {12, 13};
|
||||||
ze.attachFile("one.pdf", b, "Application/PDF", "Alternative");
|
ze.attachFile("one.pdf", b, "application/pdf", "Alternative");
|
||||||
ze.attachFile("two.pdf", b, "Application/PDF", "Alternative");
|
ze.attachFile("two.pdf", b, "application/pdf", "Alternative");
|
||||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").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(19)), price, 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(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").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(19)), price, new BigDecimal(1.0)))
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class LibraryTest extends ResourceCase {
|
|||||||
* automatically test the xrechnung
|
* automatically test the xrechnung
|
||||||
*/
|
*/
|
||||||
public void testXRValidation() {
|
public void testXRValidation() {
|
||||||
File tempFile = new File("../library/target/testout-XR.xml");
|
File tempFile = new File("../library/target/testout-XR-Edge.xml");
|
||||||
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
|
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
|
||||||
|
|
||||||
String res = zfv.validate(tempFile.getAbsolutePath());
|
String res = zfv.validate(tempFile.getAbsolutePath());
|
||||||
|
|||||||
Reference in New Issue
Block a user