kputnam / stupidedi

Ruby API for parsing and generating ASC X12 EDI transactions
BSD 3-Clause "New" or "Revised" License
265 stars 137 forks source link

TD1 for X12 Release 4010 gets reduced to 2 fields instead of 10 for no reason #260

Closed andrewchen5678 closed 1 year ago

andrewchen5678 commented 1 year ago

When I was working with edi, I noticed that TD1 got reduced to 2 fields for no reason. It should be 10 fields like other versions:

It is confirmed through here: https://www.stedi.com/edi/x12-004010/segment/TD1

lib/stupidedi/versions/004010/segment_defs/TD1.rb

Index: lib/stupidedi/versions/004010/segment_defs/TD1.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/stupidedi/versions/004010/segment_defs/TD1.rb b/lib/stupidedi/versions/004010/segment_defs/TD1.rb
--- a/lib/stupidedi/versions/004010/segment_defs/TD1.rb (revision 58be58b40dd3c4f822dad81ba18e668ed1a890fb)
+++ b/lib/stupidedi/versions/004010/segment_defs/TD1.rb (date 1689720396129)
@@ -7,12 +7,20 @@
         e = ElementDefs
         r = ElementReqs

-        # @note: Definition might be outdated, working from ANSI X12 2001 specification
+        # the gem developer reduced the field to 2 instead of 10 for no reason
         TD1 = s::SegmentDef.build(:TD1, "Carrier Details (Quantity and Weight)",
-          "To specify the transportation details relative to commodity, weight,
+                                  "To specify the transportation details relative to commodity, weight,
           and quantity",
-          e::E103 .simple_use(r::Mandatory,  s::RepeatCount.bounded(1)),
-          e::E80  .simple_use(r::Mandatory,  s::RepeatCount.bounded(1)))
+                                  e::E103 .simple_use(r::Optional,   s::RepeatCount.bounded(1)),
+                                  e::E80  .simple_use(r::Relational, s::RepeatCount.bounded(1)),
+                                  e::E23  .simple_use(r::Optional,   s::RepeatCount.bounded(1)),
+                                  e::E22  .simple_use(r::Relational, s::RepeatCount.bounded(1)),
+                                  e::E79  .simple_use(r::Optional,   s::RepeatCount.bounded(1)),
+                                  e::E187 .simple_use(r::Optional,   s::RepeatCount.bounded(1)),
+                                  e::E81  .simple_use(r::Relational, s::RepeatCount.bounded(1)),
+                                  e::E355 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
+                                  e::E183 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
+                                  e::E355 .simple_use(r::Relational, s::RepeatCount.bounded(1)))
       end
     end
   end
kputnam commented 1 year ago

Thanks for the bug report Andrew, and for citing stedi's documentation. I will accept a PR if you submit one.