corrected profile for order-x

This commit is contained in:
jstaerk
2021-12-04 15:25:00 +01:00
parent 485c96b9b6
commit 34ee9b6267
4 changed files with 58 additions and 25 deletions

View File

@@ -0,0 +1,6 @@
package org.mustangproject;
public enum EStandard {
facturx, orderx, zugferd, cii, ubl
}

View File

@@ -25,6 +25,7 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter; import org.dom4j.io.XMLWriter;
import org.mustangproject.EStandard;
import org.mustangproject.FileAttachment; import org.mustangproject.FileAttachment;
import org.mustangproject.XMLTools; import org.mustangproject.XMLTools;
@@ -48,10 +49,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
protected IExportableTransaction trans; protected IExportableTransaction trans;
protected TransactionCalculator calc; protected TransactionCalculator calc;
private String paymentTermsDescription; private String paymentTermsDescription;
protected Profile profile = Profiles.getByName("EN16931"); protected Profile profile = Profiles.getByName(EStandard.orderx,"basic", 1);
@Override @Override
@@ -124,6 +122,9 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
// + " // + "
// <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" // <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n"
// //
+ "<ram:BusinessProcessSpecifiedDocumentContextParameter>\n"
+ "<ram:ID>A1</ram:ID>\n"
+ "</ram:BusinessProcessSpecifiedDocumentContextParameter>\n"
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n" + " <ram:GuidelineSpecifiedDocumentContextParameter>\n"
+ " <ram:ID>" + getProfile().getID() + "</ram:ID>\n" + " <ram:ID>" + getProfile().getID() + "</ram:ID>\n"
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" + " </ram:GuidelineSpecifiedDocumentContextParameter>\n"
@@ -536,6 +537,11 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
profile = p; profile = p;
} }
@Override
public Profile getProfile() {
return profile;
}
private String buildPaymentTermsXml() { private String buildPaymentTermsXml() {
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms(); final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();

View File

@@ -20,6 +20,8 @@
*/ */
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import org.mustangproject.EStandard;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -41,8 +43,28 @@ public class Profiles {
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1])); }).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1]));
static Map<String, Profile> ox1Map = Stream.of(new Object[][]{
{"BASIC", new Profile("BASIC", "urn:order-x.eu:1p0:basic")},
{"COMFORT", new Profile("COMFORT", "urn:order-x.eu:1p0:comfort")},
{"EXTENDED", new Profile("EXTENDED", "urn:order-x.eu:1p0:extended")},
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1]));
public static Profile getByName(EStandard standard, String name, int version) {
if (standard != EStandard.orderx) {
return getByName(name, version);
} else {
Profile result = null;
result = ox1Map.get(name.toUpperCase());
if (result == null) {
throw new RuntimeException("Profile not found");
}
return result;
}
}
public static Profile getByName(String name, int version) { public static Profile getByName(String name, int version) {
Profile result = null; Profile result = null;
if (version == 1) { if (version == 1) {
@@ -50,9 +72,12 @@ public class Profiles {
} else { } else {
result = zf2Map.get(name.toUpperCase()); result = zf2Map.get(name.toUpperCase());
} }
if (result==null) { throw new RuntimeException("Profile not found"); } if (result == null) {
throw new RuntimeException("Profile not found");
}
return result; return result;
} }
public static Profile getByName(String name) { public static Profile getByName(String name) {
return getByName(name, ZUGFeRDExporterFromA3.DefaultZUGFeRDVersion); return getByName(name, ZUGFeRDExporterFromA3.DefaultZUGFeRDVersion);
} }

View File

@@ -288,11 +288,7 @@ public class OXTest extends MustangReaderTestCase implements IExportableTransact
assertEquals("496.00", zi.getAmount()); assertEquals("496.00", zi.getAmount());
assertEquals(zi.getHolder(), getOwnOrganisationName()); assertEquals(zi.getHolder(), getOwnOrganisationName());
assertEquals(zi.getForeignReference(), getNumber()); assertEquals(zi.getForeignReference(), getNumber());
try {
assertEquals(zi.getVersion(), 2);
} catch (Exception e) {
e.printStackTrace();
}
} }