Skip to content

Commit

Permalink
add DTM to Pack loop (856) (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSmell authored Jun 23, 2022
1 parent 169bd88 commit c7fa1bc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,7 +73,11 @@ public class Pack extends X12ParsedLoop {
* LIN: Item Identification
*/
private List<LINItemIdentification> itemIdentifications;

/*
* DTM: Date/Time Reference
*/
private List<DTMDateTimeReference> dtmReferences;

/**
* returns true if the loop passed in is a Pack loop
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -195,4 +211,11 @@ public void setN1PartyIdentifications(List<N1PartyIdentification> n1PartyIdentif
this.n1PartyIdentifications = n1PartyIdentifications;
}

public List<DTMDateTimeReference> getDtmReferences() {
return dtmReferences;
}

public void setDtmReferences(List<DTMDateTimeReference> dtmReferences) {
this.dtmReferences = dtmReferences;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@ public void test_doParse() {
assertEquals("MF", n1List.get(0).getEntityIdentifierCode());
assertEquals("VN", n1List.get(1).getEntityIdentifierCode());

List<DTMDateTimeReference> 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);

Expand Down Expand Up @@ -496,6 +502,7 @@ private List<X12Segment> 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"));
Expand Down

0 comments on commit c7fa1bc

Please sign in to comment.