Add ability to mark an Invoice as a test invoice.
This commit is contained in:
@@ -39,6 +39,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class Invoice implements IExportableTransaction {
|
||||
|
||||
protected boolean testIndicator;
|
||||
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 TradeParty sender = null, recipient = null, deliveryAddress = null, payee = null, invoicer = null, invoicee = null;
|
||||
@@ -82,6 +83,16 @@ public class Invoice implements IExportableTransaction {
|
||||
setCurrency("EUR");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTestIndicator() {
|
||||
return testIndicator;
|
||||
}
|
||||
|
||||
public Invoice setTestIndicator() {
|
||||
this.testIndicator = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDocumentName() {
|
||||
return documentName;
|
||||
|
||||
@@ -49,12 +49,6 @@ public class CustomXMLProvider implements IXMLProvider {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTest() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.mustangproject.FileAttachment;
|
||||
import org.mustangproject.IncludedNote;
|
||||
import org.mustangproject.ReferencedDocument;
|
||||
import org.mustangproject.TradeParty;
|
||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||
|
||||
/***
|
||||
@@ -49,6 +48,11 @@ import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||
*/
|
||||
public interface IExportableTransaction {
|
||||
|
||||
@JsonIgnore
|
||||
default boolean getTestIndicator() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name
|
||||
*
|
||||
|
||||
@@ -22,13 +22,9 @@ public interface IXMLProvider {
|
||||
|
||||
public byte[] getXML();
|
||||
|
||||
public void setTest();
|
||||
|
||||
public void generateXML(IExportableTransaction trans);
|
||||
|
||||
public void setProfile(Profile p);
|
||||
|
||||
public Profile getProfile();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -136,11 +136,6 @@ public class UBLDAPullProvider implements IXMLProvider {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(Profile p) {
|
||||
profile = p;
|
||||
@@ -150,5 +145,4 @@ public class UBLDAPullProvider implements IXMLProvider {
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,14 +49,6 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
||||
private String paymentTermsDescription;
|
||||
protected Profile profile = Profiles.getByName("COMFORT", 1);
|
||||
|
||||
|
||||
/**
|
||||
* enables the flag to indicate a test invoice in the XML structure
|
||||
*/
|
||||
@Override
|
||||
public void setTest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String vatFormat(BigDecimal value) {
|
||||
return XMLTools.nDigitFormat(value, 2);
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.dom4j.Document;
|
||||
@@ -61,14 +60,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
private String paymentTermsDescription;
|
||||
protected Profile profile = Profiles.getByName("EN16931");
|
||||
|
||||
|
||||
/**
|
||||
* enables the flag to indicate a test invoice in the XML structure
|
||||
*/
|
||||
@Override
|
||||
public void setTest() {
|
||||
}
|
||||
|
||||
protected String vatFormat(BigDecimal value) {
|
||||
return XMLTools.nDigitFormat(value, 2);
|
||||
}
|
||||
@@ -384,9 +375,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " xmlns:qdt=\"urn:un:unece:uncefact:data:standard:QualifiedDataType:100\">"
|
||||
+ "<!-- generated by: mustangproject.org v" + ZUGFeRD2PullProvider.class.getPackage().getImplementationVersion() + "-->"
|
||||
+ "<rsm:ExchangedDocumentContext>\n";
|
||||
// + "
|
||||
// <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>"
|
||||
//
|
||||
|
||||
if (trans.getTestIndicator()) {
|
||||
xml += "<ram:TestIndicator><udt:Indicator>" + trans.getTestIndicator() + "</udt:Indicator></ram:TestIndicator>";
|
||||
}
|
||||
|
||||
if (getProfile() == Profiles.getByName("XRechnung")) {
|
||||
xml += "<ram:BusinessProcessSpecifiedDocumentContextParameter>\n"
|
||||
|
||||
@@ -600,7 +600,7 @@ public class ZF2PushTest extends TestCase {
|
||||
ReferencedDocument dr1=new ReferencedDocument("90-kl-98798-C", sdf.parse("2025-10-12"));
|
||||
ReferencedDocument dr2=new ReferencedDocument("90-kl-98798-C1", sdf.parse("2025-10-13"));
|
||||
dr2.setReferenceTypeCode("AAG");
|
||||
ze.setTransaction(new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setPaymentReference("Verwendungszweck").setDocumentName("Rechnung")
|
||||
ze.setTransaction(new Invoice().setTestIndicator().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setPaymentReference("Verwendungszweck").setDocumentName("Rechnung")
|
||||
.setSellerOrderReferencedDocumentID("9384").setBuyerOrderReferencedDocumentID("28934")
|
||||
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo))
|
||||
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setEmail("sender@test.org").setID(orgID).addVATID("DE0815"))
|
||||
@@ -630,6 +630,7 @@ public class ZF2PushTest extends TestCase {
|
||||
|
||||
String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8);
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||
assertTrue(theXML.contains("<ram:TestIndicator"));
|
||||
ze.export(TARGET_PUSHEDGE);
|
||||
} catch (IOException e) {
|
||||
fail("IOException should not be raised");
|
||||
|
||||
Reference in New Issue
Block a user