corrected profile for order-x
This commit is contained in:
6
library/src/main/java/org/mustangproject/EStandard.java
Normal file
6
library/src/main/java/org/mustangproject/EStandard.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package org.mustangproject;
|
||||
|
||||
public enum EStandard {
|
||||
facturx, orderx, zugferd, cii, ubl
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.mustangproject.EStandard;
|
||||
import org.mustangproject.FileAttachment;
|
||||
import org.mustangproject.XMLTools;
|
||||
|
||||
@@ -48,10 +49,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
protected IExportableTransaction trans;
|
||||
protected TransactionCalculator calc;
|
||||
private String paymentTermsDescription;
|
||||
protected Profile profile = Profiles.getByName("EN16931");
|
||||
|
||||
|
||||
|
||||
protected Profile profile = Profiles.getByName(EStandard.orderx,"basic", 1);
|
||||
|
||||
|
||||
@Override
|
||||
@@ -108,7 +106,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
}
|
||||
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
|
||||
+"<rsm:SCRDMCCBDACIOMessageStructure\n" +
|
||||
+ "<rsm:SCRDMCCBDACIOMessageStructure\n" +
|
||||
"xmlns:rsm=\"urn:un:unece:uncefact:data:SCRDMCCBDACIOMessageStructure:100\"\n" +
|
||||
"xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:128\"\n" +
|
||||
"xmlns:qdt=\"urn:un:unece:uncefact:data:standard:QualifiedDataType:128\"\n" +
|
||||
@@ -124,6 +122,9 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
// + "
|
||||
// <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:ID>" + getProfile().getID() + "</ram:ID>\n"
|
||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||
@@ -318,9 +319,9 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
|
||||
if (trans.getSpecifiedProcuringProjectID() != null) {
|
||||
xml = xml + " <ram:SpecifiedProcuringProject>\n"
|
||||
+ " <ram:ID>"
|
||||
+ XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>\n";
|
||||
if(trans.getSpecifiedProcuringProjectName()!= null) {
|
||||
+ " <ram:ID>"
|
||||
+ XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>\n";
|
||||
if (trans.getSpecifiedProcuringProjectName() != null) {
|
||||
xml += " <ram:Name >" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + "</ram:Name>\n";
|
||||
}
|
||||
xml += " </ram:SpecifiedProcuringProject>\n";
|
||||
@@ -337,7 +338,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
+ " <ram:OccurrenceDateTime>";
|
||||
|
||||
if (trans.getDeliveryDate() != null) {
|
||||
xml += DATE.udtFormat(trans.getDeliveryDate());
|
||||
xml += DATE.udtFormat(trans.getDeliveryDate());
|
||||
} else {
|
||||
throw new IllegalStateException("No delivery date provided");
|
||||
}
|
||||
@@ -499,10 +500,10 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
xml = xml + " <ram:InvoiceReferencedDocument>\n"
|
||||
+ " <ram:IssuerAssignedID>"
|
||||
+ XMLTools.encodeXML(trans.getInvoiceReferencedDocumentID()) + "</ram:IssuerAssignedID>\n";
|
||||
if(trans.getInvoiceReferencedIssueDate()!= null){
|
||||
xml += "<ram:FormattedIssueDateTime>"
|
||||
+ DATE.qdtFormat(trans.getInvoiceReferencedIssueDate())
|
||||
+ "</ram:FormattedIssueDateTime>\n";
|
||||
if (trans.getInvoiceReferencedIssueDate() != null) {
|
||||
xml += "<ram:FormattedIssueDateTime>"
|
||||
+ DATE.qdtFormat(trans.getInvoiceReferencedIssueDate())
|
||||
+ "</ram:FormattedIssueDateTime>\n";
|
||||
}
|
||||
xml += " </ram:InvoiceReferencedDocument>\n";
|
||||
}
|
||||
@@ -536,6 +537,11 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
profile = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
private String buildPaymentTermsXml() {
|
||||
|
||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
||||
@@ -553,7 +559,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
|
||||
if (dueDate != null) {
|
||||
paymentTermsXml += "<ram:DueDateDateTime>";
|
||||
paymentTermsXml += DATE.udtFormat(dueDate) ;
|
||||
paymentTermsXml += DATE.udtFormat(dueDate);
|
||||
paymentTermsXml += "</ram:DueDateDateTime>";
|
||||
}
|
||||
|
||||
@@ -568,7 +574,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
if (discountTerms.getBaseDate() != null) {
|
||||
final Date baseDate = discountTerms.getBaseDate();
|
||||
paymentTermsXml += "<ram:BasisDateTime>";
|
||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||
paymentTermsXml += "</ram:BasisDateTime>";
|
||||
|
||||
paymentTermsXml += "<ram:BasisPeriodMeasure unitCode=\"" + discountTerms.getBasePeriodUnitCode() + "\">"
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package org.mustangproject.ZUGFeRD;
|
||||
|
||||
import org.mustangproject.EStandard;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -41,18 +43,41 @@ public class Profiles {
|
||||
|
||||
|
||||
}).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) {
|
||||
Profile result=null;
|
||||
if (version==1) {
|
||||
result=zf1Map.get(name.toUpperCase());
|
||||
Profile result = null;
|
||||
if (version == 1) {
|
||||
result = zf1Map.get(name.toUpperCase());
|
||||
} 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;
|
||||
}
|
||||
|
||||
public static Profile getByName(String name) {
|
||||
return getByName(name, ZUGFeRDExporterFromA3.DefaultZUGFeRDVersion);
|
||||
}
|
||||
|
||||
@@ -288,11 +288,7 @@ public class OXTest extends MustangReaderTestCase implements IExportableTransact
|
||||
assertEquals("496.00", zi.getAmount());
|
||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||
assertEquals(zi.getForeignReference(), getNumber());
|
||||
try {
|
||||
assertEquals(zi.getVersion(), 2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user