Add ability to mark an Invoice as a test invoice.

This commit is contained in:
langfr
2026-03-06 11:52:00 +00:00
parent a59fce7dab
commit 53c055576c
8 changed files with 22 additions and 38 deletions

View File

@@ -39,6 +39,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Invoice implements IExportableTransaction { 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 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 TradeParty sender = null, recipient = null, deliveryAddress = null, payee = null, invoicer = null, invoicee = 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"); setCurrency("EUR");
} }
@Override
public boolean getTestIndicator() {
return testIndicator;
}
public Invoice setTestIndicator() {
this.testIndicator = true;
return this;
}
@Override @Override
public String getDocumentName() { public String getDocumentName() {
return documentName; return documentName;

View File

@@ -49,12 +49,6 @@ public class CustomXMLProvider implements IXMLProvider {
} }
@Override
public void setTest() {
// TODO Auto-generated method stub
}
@Override @Override
public Profile getProfile() { public Profile getProfile() {
return profile; return profile;

View File

@@ -38,7 +38,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import org.mustangproject.FileAttachment; import org.mustangproject.FileAttachment;
import org.mustangproject.IncludedNote; import org.mustangproject.IncludedNote;
import org.mustangproject.ReferencedDocument; import org.mustangproject.ReferencedDocument;
import org.mustangproject.TradeParty;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
/*** /***
@@ -49,6 +48,11 @@ import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
*/ */
public interface IExportableTransaction { public interface IExportableTransaction {
@JsonIgnore
default boolean getTestIndicator() {
return false;
}
/** /**
* appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name * appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name
* *

View File

@@ -22,13 +22,9 @@ public interface IXMLProvider {
public byte[] getXML(); public byte[] getXML();
public void setTest();
public void generateXML(IExportableTransaction trans); public void generateXML(IExportableTransaction trans);
public void setProfile(Profile p); public void setProfile(Profile p);
public Profile getProfile(); public Profile getProfile();
} }

View File

@@ -136,11 +136,6 @@ public class UBLDAPullProvider implements IXMLProvider {
} }
@Override
public void setTest() {
}
@Override @Override
public void setProfile(Profile p) { public void setProfile(Profile p) {
profile = p; profile = p;
@@ -150,5 +145,4 @@ public class UBLDAPullProvider implements IXMLProvider {
public Profile getProfile() { public Profile getProfile() {
return profile; return profile;
} }
} }

View File

@@ -49,14 +49,6 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
private String paymentTermsDescription; private String paymentTermsDescription;
protected Profile profile = Profiles.getByName("COMFORT", 1); protected Profile profile = Profiles.getByName("COMFORT", 1);
/**
* enables the flag to indicate a test invoice in the XML structure
*/
@Override
public void setTest() {
}
@Override @Override
protected String vatFormat(BigDecimal value) { protected String vatFormat(BigDecimal value) {
return XMLTools.nDigitFormat(value, 2); return XMLTools.nDigitFormat(value, 2);

View File

@@ -35,7 +35,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.dom4j.Document; import org.dom4j.Document;
@@ -61,14 +60,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
private String paymentTermsDescription; private String paymentTermsDescription;
protected Profile profile = Profiles.getByName("EN16931"); 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) { protected String vatFormat(BigDecimal value) {
return XMLTools.nDigitFormat(value, 2); return XMLTools.nDigitFormat(value, 2);
} }
@@ -384,9 +375,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " xmlns:qdt=\"urn:un:unece:uncefact:data:standard:QualifiedDataType:100\">" + " xmlns:qdt=\"urn:un:unece:uncefact:data:standard:QualifiedDataType:100\">"
+ "<!-- generated by: mustangproject.org v" + ZUGFeRD2PullProvider.class.getPackage().getImplementationVersion() + "-->" + "<!-- generated by: mustangproject.org v" + ZUGFeRD2PullProvider.class.getPackage().getImplementationVersion() + "-->"
+ "<rsm:ExchangedDocumentContext>\n"; + "<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")) { if (getProfile() == Profiles.getByName("XRechnung")) {
xml += "<ram:BusinessProcessSpecifiedDocumentContextParameter>\n" xml += "<ram:BusinessProcessSpecifiedDocumentContextParameter>\n"

View File

@@ -600,7 +600,7 @@ public class ZF2PushTest extends TestCase {
ReferencedDocument dr1=new ReferencedDocument("90-kl-98798-C", sdf.parse("2025-10-12")); 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")); ReferencedDocument dr2=new ReferencedDocument("90-kl-98798-C1", sdf.parse("2025-10-13"));
dr2.setReferenceTypeCode("AAG"); 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") .setSellerOrderReferencedDocumentID("9384").setBuyerOrderReferencedDocumentID("28934")
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo)) .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")) .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); String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8);
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice")); assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
assertTrue(theXML.contains("<ram:TestIndicator"));
ze.export(TARGET_PUSHEDGE); ze.export(TARGET_PUSHEDGE);
} catch (IOException e) { } catch (IOException e) {
fail("IOException should not be raised"); fail("IOException should not be raised");