kputnam / stupidedi

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

214: E66, E706 elements declared mandatory #85

Closed gisborne closed 8 years ago

gisborne commented 8 years ago

I'm trying to create a 214 (Carrier Shipment Status Notification). I'm trying to create the N1 element,

b.N1 "SH", "SILVERADO VINEYARDS C/O DFS", "1"

but I'm being told that N103 and N104 elements are required.

Stupidedi::Exceptions::ParseError: value is too short in element N103

This would appear to be in functional_groups/004010/segment_defs/N1.rb.

I'm a little new to this EDI business, but from specifications I read (eg http://www.ryder.com/supply-chain/~/media/Ryder/Files/SupplyChain/EDIspecs/carrier_214.ashx) that these elements should not be marked as required.

I believe the correct code would be:

          N1  = s::SegmentDef.build(:N1, "Name",
            "To identify a party by type of organization, name, and code",
            e::E98  .simple_use(r::Mandatory,  s::RepeatCount.bounded(1)),
            e::E93  .simple_use(r::Mandatory, s::RepeatCount.bounded(1)),
            e::E66  .simple_use(r::Optional, s::RepeatCount.bounded(1)),
            e::E67  .simple_use(r::Optional, s::RepeatCount.bounded(1)),
            e::E706 .simple_use(r::Optional,   s::RepeatCount.bounded(1)),
            e::E98  .simple_use(r::Optional,   s::RepeatCount.bounded(1)),

Many thanks for this project, and for your help.

kputnam commented 8 years ago

Based on the error message, value is too short in element NM103, it looks like you did provide a single-character value "1". The element type is E66, which is declared to require 2-3 characters. However the list of allowed values clearly has values with a single character, so I agree this looks like an error. I don't think we have the official documentation for 4010, but further evidence is that the length is declared 1-2 in the 5010 version of E66.

@irobayna if you have time, could you check for documentation on that element? I think you made the commit to declare it, so maybe there was a reason it was declared length 2-3 (but it does look like a simple mistake). If you find that it should be 1-2, or can't find any documentation, we should probably change it to 1-2 for the other versions too, since it looks like those were copy-pasted from 4010.

You didn't include the error message about NM104 being required, but the error is because of the relationship between the two elements (the error message could probably be clearer). This line declares a relationship between NM103 and NM104 of type P, which means if one of the two are present, then both are required. You could leave them both blank or fill them both in, but providing only one value is not allowed.

kputnam commented 8 years ago

@gisborne Out of curiosity, did the error about NM104 state elements NM104 must be present when elements NM103 are present? If not, please paste the error you saw... I'll want to correct that if it wasn't the case.

gisborne commented 8 years ago

I'm doing: builder.N1 "SH", sender and being told: Stupidedi::Exceptions::ParseError: required element N103 is blank

irobayna commented 8 years ago

@kputnam Yes, it was a mistake

It appears the Min/Max declaration should have been 1/2

BTW, you are also correct on the syntax rules. These are defined as follows for N1

Syntax Rules:
1. R0203 - At least one of N102 or N103 is required.
2. P0304 - If either N103 or N104 is present, then the other is required.
irobayna commented 8 years ago

@kputnam I have committed change to master

kputnam commented 8 years ago

Thanks Isi!

gisborne commented 8 years ago

Please update lib/stupidedi/version.rb with a new version number so bundler notices the change and I can update.

irobayna commented 8 years ago

@gisborne new version available