deliveradvice corrections
This commit is contained in:
@@ -23,9 +23,13 @@ import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mustangproject.EStandard;
|
||||
import org.mustangproject.Invoice;
|
||||
import org.mustangproject.TradeParty;
|
||||
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
@@ -38,6 +42,8 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class DXTest extends MustangReaderTestCase implements IExportableTransaction {
|
||||
final String TARGET_PDF = "./target/testout-DX.pdf";
|
||||
@@ -198,10 +204,10 @@ public class DXTest extends MustangReaderTestCase implements IExportableTransact
|
||||
EdgeProduct designProduct = new EdgeProduct("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung",
|
||||
"HUR");
|
||||
EdgeProduct balloonProduct = new EdgeProduct("", "Bestellerweiterung für E&F Umbau", "C62");// test for issue
|
||||
// 103
|
||||
// 103
|
||||
EdgeProduct airProduct = new EdgeProduct("", "Heiße Luft pro Liter", "LTR");
|
||||
|
||||
Item design=new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
||||
Item design = new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
||||
design.setAddReference("1825");
|
||||
allItems[0] = design;
|
||||
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("400"), balloonProduct);
|
||||
@@ -268,8 +274,8 @@ public class DXTest extends MustangReaderTestCase implements IExportableTransact
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||
|
||||
DXExporterFromA1 oe = new DXExporterFromA1().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(1).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(1).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
oe.setTransaction(this);
|
||||
String theXML = new String(oe.getProvider().getXML(), StandardCharsets.UTF_8);
|
||||
assertTrue(theXML.contains("<rsm:SCRDMCCBDACIOMessageStructure"));
|
||||
@@ -292,7 +298,7 @@ public class DXTest extends MustangReaderTestCase implements IExportableTransact
|
||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(TARGET_PDF);
|
||||
try {
|
||||
Invoice i=zii.extractInvoice();
|
||||
Invoice i = zii.extractInvoice();
|
||||
|
||||
assertEquals(new BigDecimal("400.0000"), i.getZFItems()[1].getQuantity());
|
||||
/* getting the Quantity is more difficult than usual because in OrderX it's
|
||||
@@ -311,4 +317,55 @@ public class DXTest extends MustangReaderTestCase implements IExportableTransact
|
||||
|
||||
}
|
||||
|
||||
public void testDAGeneration() {
|
||||
|
||||
// the writing part
|
||||
TradeParty recipient = new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE");
|
||||
Invoice i = createDA(recipient);
|
||||
|
||||
DAPullProvider zf2p = new DAPullProvider();
|
||||
zf2p.setProfile(Profiles.getByName(EStandard.deliveradvice,"Pilot",1));
|
||||
zf2p.generateXML(i);
|
||||
String theXML = new String(zf2p.getXML(), StandardCharsets.UTF_8);
|
||||
try {
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(TARGET_XML));
|
||||
writer.write(theXML);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertTrue(theXML.contains("<SCRDMCCBDACIDAMessageStructure"));
|
||||
assertThat(theXML).valueByXPath("count(//*[local-name()='IncludedSupplyChainTradeLineItem'])")
|
||||
.asInt()
|
||||
.isEqualTo(2); //we have two items
|
||||
|
||||
|
||||
assertThat(theXML).valueByXPath("//*[local-name()='ActualDespatchSupplyChainEvent']/*[local-name()='OccurrenceDateTime']/*[local-name()='DateTimeString']")
|
||||
.asString()
|
||||
.isEqualToIgnoringWhitespace("20210426");
|
||||
|
||||
|
||||
|
||||
}
|
||||
private Invoice createDA(TradeParty recipient) {
|
||||
String orgname = "Test company";
|
||||
String number = "123";
|
||||
String amountStr = "23.00";
|
||||
BigDecimal amount = new BigDecimal(amountStr);
|
||||
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||
|
||||
try {
|
||||
return 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 org.mustangproject.Contact("Hans Test","+49123456789","test@example.org")).addBankDetails(new org.mustangproject.BankDetails("DE12500105170648489890","COBADEFXXX")))
|
||||
.setRecipient(recipient)
|
||||
.setDeliveryDate(germanDateFormat.parse("26.04.2021"))
|
||||
.setReferenceNumber("991-01484-64")//leitweg-id
|
||||
// not using any VAT, this is also a test of zero-rated goods:
|
||||
.setNumber(number)
|
||||
.addItem(new org.mustangproject.Item(new org.mustangproject.Product("Testprodukt", "", "P75", BigDecimal.ZERO), amount, new BigDecimal(1.0))).addItem(new org.mustangproject.Item(new org.mustangproject.Product("Testprodukt", "", "P85", BigDecimal.ZERO), amount, new BigDecimal(1.0)));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user