Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
5656-app - EDI-Tweaks
Browse files Browse the repository at this point in the history
* make ApplicationRef configurable per recipient-GLN
metasfresh/metasfresh#5656
  • Loading branch information
metas-ts committed Nov 7, 2019
1 parent f505098 commit a8b03ad
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
Expand Up @@ -103,7 +103,6 @@ private Document createDesadvDocumentFromXMLBean(@NonNull final EDIExpDesadvType
final String dateFormat = (String)exchange.getProperty(AbstractEDIRoute.EDI_ORDER_EDIMessageDatePattern);

final String ownerId = exchange.getProperty(StepComXMLDesadvRoute.EDI_XML_OWNER_ID, String.class);
final String applicationRef = exchange.getProperty(StepComXMLDesadvRoute.EDI_XML_APPLICATION_REF, String.class);
final String supplierGln = exchange.getProperty(StepComXMLDesadvRoute.EDI_XML_SUPPLIER_GLN, String.class);

xmlDesadv.getEDIExpDesadvLine().sort(Comparator.comparing(EDIExpDesadvLineType::getLine));
Expand All @@ -121,7 +120,7 @@ private Document createDesadvDocumentFromXMLBean(@NonNull final EDIExpDesadvType
header.setOWNERID(ownerId);
header.setTESTINDICATOR(receiverSettings.getTestIndicator());
header.setMESSAGEREF(formatNumber(xmlDesadv.getSequenceNoAttr(), decimalFormat));
header.setAPPLICATIONREF(applicationRef);
header.setAPPLICATIONREF(receiverSettings.getApplicationRef());
header.setDOCUMENTTYP(DocumentType.DADV.toString());
header.setDOCUMENTFUNCTION(DocumentFunction.ORIG.toString());

Expand Down
Expand Up @@ -126,7 +126,6 @@ private Document createDocument(final Exchange exchange, final EDICctopInvoicVTy
{
final DecimalFormat decimalFormat = exchange.getProperty(Constants.DECIMAL_FORMAT, DecimalFormat.class);
final String ownerId = exchange.getProperty(StepComXMLInvoicRoute.EDI_XML_OWNER_ID, String.class);
final String applicationRef = exchange.getProperty(StepComXMLInvoicRoute.EDI_XML_APPLICATION_REF, String.class);

final Document document = INVOIC_objectFactory.createDocument();
final Xrech4H xrech4H = INVOIC_objectFactory.createXrech4H();
Expand All @@ -137,7 +136,7 @@ private Document createDocument(final Exchange exchange, final EDICctopInvoicVTy
headerXrech.setTESTINDICATOR(invoicSettings.getTestIndicator());

headerXrech.setPARTNERID(invoicSettings.getPartnerId());
headerXrech.setAPPLICATIONREF(applicationRef);
headerXrech.setAPPLICATIONREF(invoicSettings.getApplicationRef());
headerXrech.setOWNERID(ownerId);
final String documentId = invoice.getInvoiceDocumentno();
headerXrech.setDOCUMENTID(documentId);
Expand Down
Expand Up @@ -37,7 +37,8 @@ public static StepComDesadvSettings forReceiverGLN(
{
return StepComDesadvSettings
.builder()
.partnerId(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".partnerId"))
.applicationRef(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".desadv.applicationRef", "DESADV"))
.partnerId(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".desadv.partnerId"))
.testIndicator(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".desadv.testIndicator", "T"))
.desadvLinePackagingCodeTURequired(Util.resolvePropertyAsBool(context, "edi.stepcom.recipientGLN." + recipientGLN + ".desadv.line.packagingCodeTU.required", "false"))
.desadvLineORBU(Util.resolvePropertyAsBool(context, "edi.stepcom.recipientGLN." + recipientGLN + ".desadv.line.ORBU", "false"))
Expand All @@ -47,6 +48,8 @@ public static StepComDesadvSettings forReceiverGLN(
.build();
}

String applicationRef;

String partnerId;

String testIndicator;
Expand Down
Expand Up @@ -38,7 +38,8 @@ public static StepComInvoicSettings forReceiverGLN(
{
return StepComInvoicSettings
.builder()
.partnerId(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".partnerId"))
.applicationRef(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".invoic.applicationRef", "INVOIC"))
.partnerId(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".invoic.partnerId"))
.testIndicator(Util.resolveProperty(context, "edi.stepcom.recipientGLN." + recipientGLN + ".invoic.testIndicator", "T"))

.invoicBUYRAddressName1Required(Util.resolvePropertyAsBool(context, "edi.stepcom.recipientGLN." + recipientGLN + ".invoic.BUYR.AddressName1.required", "true"))
Expand All @@ -57,6 +58,8 @@ public static StepComInvoicSettings forReceiverGLN(
.build();
}

String applicationRef;

String partnerId;

String testIndicator;
Expand Down
Expand Up @@ -54,7 +54,6 @@ public class StepComXMLDesadvRoute extends AbstractEDIRoute
public static final String EP_EDI_STEPCOM_XML_DESADV_CONSUMER = "direct:edi.xml.desadv.consumer";

public static final String EDI_XML_OWNER_ID = "edi.props.stepcom.owner.id";
public static final String EDI_XML_APPLICATION_REF = "edi.props.stepcom.application.ref";

public static final String EDI_XML_SUPPLIER_GLN = "edi.props.desadv.stepcom.supplier.gln";

Expand Down Expand Up @@ -84,7 +83,6 @@ public void configureEDIRoute(final DataFormat jaxb, final DecimalFormat decimal
final String desadvFilenamePattern = Util.resolveProperty(getContext(), StepComXMLDesadvRoute.EDI_DESADV_XML_FILENAME_PATTERN);

final String ownerId = Util.resolveProperty(getContext(), StepComXMLDesadvRoute.EDI_XML_OWNER_ID);
final String applicationRef = Util.resolveProperty(getContext(), StepComXMLDesadvRoute.EDI_XML_APPLICATION_REF);
final String supplierGln = Util.resolveProperty(getContext(), StepComXMLDesadvRoute.EDI_XML_SUPPLIER_GLN);

final String defaultEDIMessageDatePattern = Util.resolveProperty(getContext(), StepComXMLDesadvRoute.EDI_ORDER_EDIMessageDatePattern);
Expand All @@ -95,7 +93,6 @@ public void configureEDIRoute(final DataFormat jaxb, final DecimalFormat decimal

.log(LoggingLevel.INFO, "EDI: Setting defaults as exchange properties...")
.setProperty(StepComXMLDesadvRoute.EDI_XML_OWNER_ID).constant(ownerId)
.setProperty(StepComXMLDesadvRoute.EDI_XML_APPLICATION_REF).constant(applicationRef)
.setProperty(StepComXMLDesadvRoute.EDI_XML_SUPPLIER_GLN).constant(supplierGln)
.setProperty(StepComXMLDesadvRoute.EDI_ORDER_EDIMessageDatePattern).constant(defaultEDIMessageDatePattern)

Expand Down
Expand Up @@ -54,7 +54,6 @@ public class StepComXMLInvoicRoute extends AbstractEDIRoute
public static final String EP_EDI_STEPCOM_XML_INVOICE_CONSUMER = "direct:edi.invoic.stepcom-xml.consumer";

public static final String EDI_XML_OWNER_ID = "edi.props.stepcom.owner.id";
public static final String EDI_XML_APPLICATION_REF = "edi.props.stepcom.application.ref";

private static final String EDI_INVOICE_SENDER_GLN = "edi.props.000.sender.gln";

Expand Down Expand Up @@ -84,7 +83,6 @@ public void configureEDIRoute(final DataFormat jaxb, final DecimalFormat decimal

final String senderGln = Util.resolveProperty(getContext(), EDI_INVOICE_SENDER_GLN);
final String ownerId = Util.resolveProperty(getContext(), EDI_XML_OWNER_ID);
final String applicationRef = Util.resolveProperty(getContext(), EDI_XML_APPLICATION_REF);
final String defaultEDIMessageDatePattern = Util.resolveProperty(getContext(), AbstractEDIRoute.EDI_ORDER_EDIMessageDatePattern);
final String feedbackMessageRoutingKey = Util.resolveProperty(getContext(), Constants.EP_AMQP_TO_AD_DURABLE_ROUTING_KEY);

Expand All @@ -94,7 +92,6 @@ public void configureEDIRoute(final DataFormat jaxb, final DecimalFormat decimal
.log(LoggingLevel.INFO, "EDI: Setting defaults as exchange properties...")
.setProperty(EDI_INVOICE_SENDER_GLN).constant(senderGln)
.setProperty(EDI_XML_OWNER_ID).constant(ownerId)
.setProperty(EDI_XML_APPLICATION_REF).constant(applicationRef)
.setProperty(AbstractEDIRoute.EDI_ORDER_EDIMessageDatePattern).constant(defaultEDIMessageDatePattern)

.log(LoggingLevel.INFO, "EDI: Setting EDI feedback headers...")
Expand Down
12 changes: 8 additions & 4 deletions src/main/resources/application.properties
Expand Up @@ -8,8 +8,9 @@ server.port=8184
#
# Recipient specific stepCOM settings
#
# Specifies that the BPartner with EDI recipient GLN 1234567890123 get the PARTNERID==STEPCOM-PARTNERID in the stepCOM EDI file that we export
edi.stepcom.recipientGLN.1234567890123.partnerId=<NO_DETAULT_WILL_FAIL_IF_NOT_SET>
# Specifies that the BPartner with EDI recipient GLN 1234567890123 get the PARTNERID==STEPCOM-PARTNERID in the stepCOM DESADV file that we export
edi.stepcom.recipientGLN.1234567890123.desadv.partnerId=<NO_DETAULT_WILL_FAIL_IF_NOT_SET>
edi.stepcom.recipientGLN.1234567890123.desadv.applicationRef=DESADV
# T means "test; empty (i.e. just "...testIndicator=") means production
edi.stepcom.recipientGLN.1234567890123.desadv.testIndicator=T
# ORBU = "Order Number (buyer)"
Expand All @@ -25,6 +26,10 @@ edi.stepcom.recipientGLN.1234567890123.desadv.line.PRIC.required=false
edi.stepcom.recipientGLN.1234567890123.desadv.line.LINR=true
# If "true", then include the TU packaging code in the desadv. If the code is missing, throw an error
edi.stepcom.recipientGLN.1234567890123.desadv.line.packagingCodeTU.required=false

# same desadv.partnerId (you didn't assume that same GLN means same PartnerID for desadv and invoice, did you ;-) )
edi.stepcom.recipientGLN.1234567890123.invoic.partnerId=<NO_DETAULT_WILL_FAIL_IF_NOT_SET>
edi.stepcom.recipientGLN.1234567890123.invoic.applicationRef=INVOIC
# same as desadv.testIndicator: T means "test; empty (i.e. just "...testIndicator=") means production
edi.stepcom.recipientGLN.1234567890123.invoic.testIndicator=T
# If "true" and the buyer's respective address-fields are missing, throw an error
Expand Down Expand Up @@ -134,8 +139,7 @@ edi.props.000.sender.gln=9876543210987

#owner id used in the document header
edi.props.stepcom.owner.id=CHEESE
#application ref used in the document header
edi.props.stepcom.application.ref=metasfresh

#supplier gln used for desadv supplier address
edi.props.desadv.stepcom.supplier.gln=9876543210987

Expand Down

0 comments on commit a8b03ad

Please sign in to comment.