From c7fa1bca19dc823ceb4a6f5e9189995d921b22c2 Mon Sep 17 00:00:00 2001 From: Mike Barlotta Date: Thu, 23 Jun 2022 16:33:59 -0400 Subject: [PATCH] add DTM to Pack loop (856) (#145) --- .../DefaultAsn856TransactionSetParser.java | 4 +++ .../x12/standard/txset/asn856/loop/Pack.java | 25 ++++++++++++++++++- ...DefaultAsn856TransactionSetParserTest.java | 7 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParser.java b/src/main/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParser.java index d5362e7..f068299 100644 --- a/src/main/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParser.java +++ b/src/main/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParser.java @@ -525,6 +525,10 @@ private void doPackSegments(X12Segment segment, SegmentIterator segmentIterator, case SN1ItemDetail.IDENTIFIER: pack.setSn1(SN1ItemDetailParser.parse(segment)); break; + case DTMDateTimeReference.IDENTIFIER: + DTMDateTimeReference dtm = DTMDateTimeReferenceParser.parse(segment); + pack.addDTMDateTimeReference(dtm); + break; default: pack.addUnparsedSegment(segment); break; diff --git a/src/main/java/com/walmartlabs/x12/standard/txset/asn856/loop/Pack.java b/src/main/java/com/walmartlabs/x12/standard/txset/asn856/loop/Pack.java index 4ae38dc..ce73cf0 100644 --- a/src/main/java/com/walmartlabs/x12/standard/txset/asn856/loop/Pack.java +++ b/src/main/java/com/walmartlabs/x12/standard/txset/asn856/loop/Pack.java @@ -16,6 +16,7 @@ package com.walmartlabs.x12.standard.txset.asn856.loop; +import com.walmartlabs.x12.common.segment.DTMDateTimeReference; import com.walmartlabs.x12.common.segment.LINItemIdentification; import com.walmartlabs.x12.common.segment.N1PartyIdentification; import com.walmartlabs.x12.common.segment.PIDProductIdentification; @@ -72,7 +73,11 @@ public class Pack extends X12ParsedLoop { * LIN: Item Identification */ private List itemIdentifications; - + /* + * DTM: Date/Time Reference + */ + private List dtmReferences; + /** * returns true if the loop passed in is a Pack loop */ @@ -138,6 +143,17 @@ public void addN1PartyIdentification(N1PartyIdentification n1) { } n1PartyIdentifications.add(n1); } + + /** + * helper method to add DTM to list + * @param dtm + */ + public void addDTMDateTimeReference(DTMDateTimeReference dtm) { + if (CollectionUtils.isEmpty(dtmReferences)) { + dtmReferences = new ArrayList<>(); + } + dtmReferences.add(dtm); + } public PO4ItemPhysicalDetail getPo4() { return po4; @@ -195,4 +211,11 @@ public void setN1PartyIdentifications(List n1PartyIdentif this.n1PartyIdentifications = n1PartyIdentifications; } + public List getDtmReferences() { + return dtmReferences; + } + + public void setDtmReferences(List dtmReferences) { + this.dtmReferences = dtmReferences; + } } diff --git a/src/test/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParserTest.java b/src/test/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParserTest.java index fc4b8bc..d09e404 100644 --- a/src/test/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParserTest.java +++ b/src/test/java/com/walmartlabs/x12/standard/txset/asn856/DefaultAsn856TransactionSetParserTest.java @@ -378,6 +378,12 @@ public void test_doParse() { assertEquals("MF", n1List.get(0).getEntityIdentifierCode()); assertEquals("VN", n1List.get(1).getEntityIdentifierCode()); + List dtmList = pack.getDtmReferences(); + assertNotNull(dtmList); + assertEquals(1, dtmList.size()); + assertEquals("510", dtmList.get(0).getDateTimeQualifier()); + assertEquals("20220623", dtmList.get(0).getDate()); + unparsedSegments = pack.getUnparsedSegments(); assertNull(unparsedSegments); @@ -496,6 +502,7 @@ private List getTransactionSetSegments(String firstLoopCode, String txSegments.add(new X12Segment("MAN*UC*10081131916933")); txSegments.add(new X12Segment("N1*MF*Manufacturer*92*000062535")); txSegments.add(new X12Segment("N1*VN*Vendor*ZZ*0263")); + txSegments.add(new X12Segment("DTM*510*20220623")); // Item txSegments.add(new X12Segment("HL*6*5*I"));