Skip to content

Commit fd7f066

Browse files
authored
Merge pull request #276 from adriand/feature/4010-definition-fixes
Feature/4010 definition fixes
2 parents f382e34 + e356422 commit fd7f066

File tree

5 files changed

+139
-14
lines changed

5 files changed

+139
-14
lines changed

lib/stupidedi/versions/004010/element_defs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module ElementDefs
5454
"RD" => "Ramp to Door",
5555
"RE" => "Ramp to Ramp",
5656
"RR" => "Roll-on Roll-off"))
57-
E58 = t:: R.new(:E58 , "Charge" , 1, 12)
57+
E58 = t:: Nn.new(:E58 , "Charge" , 1, 12, 2)
5858
E59 = t::AN.new(:E59 , "Freight Class Code" , 2, 5)
5959
E60 = t:: R.new(:E60 , "Freight Rate" , 1, 9)
6060
E61 = t::AN.new(:E61 , "Free-Form Message" , 1, 30)
@@ -5140,7 +5140,7 @@ module ElementDefs
51405140
"1" => "Current Transaction Trace Numbers",
51415141
"2" => "Referenced Transaction Trace Numbers"))
51425142
E499 = t::AN.new(:E499 , "Condition Value" , 1, 10)
5143-
E501 = t::ID.new(:E501 , "Customes Document Handling Code" , 2, 2)
5143+
E501 = t::ID.new(:E501 , "Customs Documentation Handling Code" , 2, 2)
51445144
E506 = t::ID.new(:E506 , "DFI Identification Number Qualifier" , 2, 2,
51455145
s::CodeList.build(
51465146
"01" => s::CodeList.external("4"),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module SegmentDefs
88
r = ElementReqs
99

1010
C3 = s::SegmentDef.build(:C3, "Currency",
11-
"To Specify the currency being used in the transaction set",
11+
"To specify the currency being used in the transaction set",
1212
e::E100 .simple_use(r::Mandatory, s::RepeatCount.bounded(1)),
1313
e::E280 .simple_use(r::Optional, s::RepeatCount.bounded(1)),
1414
e::E100 .simple_use(r::Optional, s::RepeatCount.bounded(1)))

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@ module SegmentDefs
77
e = ElementDefs
88
r = ElementReqs
99

10-
OID = s::SegmentDef.build(:OID, "Order identification",
11-
"",
12-
e::E127 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
13-
e::E324 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
14-
e::E355 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
15-
e::E380 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
16-
e::E188 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
17-
e::E81 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
18-
e::E184 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
19-
e::E183 .simple_use(r::Relational, s::RepeatCount.bounded(1)),
10+
OID = s::SegmentDef.build(:OID, "Order Identification Detail",
11+
"To specify order identification detail",
12+
e::E127 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 30
13+
e::E324 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 22
14+
e::E127 .simple_use(r::Optional, s::RepeatCount.bounded(1)), # Min 30
15+
e::E355 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 2
16+
e::E380 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 15
17+
e::E188 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 1
18+
e::E81 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 10
19+
e::E184 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 1
20+
e::E183 .simple_use(r::Relational, s::RepeatCount.bounded(1)), # Min 8
2021
SyntaxNotes::R.build(1, 2),
2122
SyntaxNotes::C.build(3, 2),
2223
SyntaxNotes::P.build(4, 5),
2324
SyntaxNotes::P.build(6, 7),
24-
SyntaxNotes::P.build(8, 9))
25+
SyntaxNotes::P.build(8, 9)
26+
)
2527
end
2628
end
2729
end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ISA*00* *00* *14*SENDER000111111*02*RECEIVER0002222*220822*1004*U*00401*000013309*0*T*|~
2+
GS*SM*SENDER000111111*RECD*20220822*1004*13309*X*004010~
3+
ST*204*13309~
4+
B2****12345678*L*PP*L~
5+
B2A*00*LT~
6+
L11*RECD*SCA~
7+
L11*354.02*FU~
8+
L11*RBU*DP~
9+
L11*666555*SI~
10+
L11*888777*SI~
11+
L11*ZZ*EQ~
12+
G62*64*20220822*1*1120*ET~
13+
NTE*TRA*NOTE1~
14+
NTE*TRA*NOTE2~
15+
N7**ZZ*********TL~
16+
S5*1*LD*21230.12*L*0*PC*0*E~
17+
G62*69*20220823*U*1630*CD~
18+
PLD*37~
19+
NTE*TRA*NOTE3~
20+
NTE*TRA*NOTE4~
21+
N1*SF*FAKE_BIZ*93*A9~
22+
N3*700 RODNEY AUSTIN~
23+
N4*ATTALLA*AL*12345*USA~
24+
G61*SH*RECEIVING*TE*256-538-1111~
25+
OID*4728162872*9999999-01**PC*0*L*8888.88*E*0~
26+
L5***RBU*N~
27+
AT8*G*L*8888.88***E*0~
28+
G61*ZZ*ZZ~
29+
L11*RBU*DP~
30+
L11*237291298-01*DJ~
31+
L11*22982719*SI~
32+
OID*2231522233*27281628-01**PC*0*L*12341.24*E*0~
33+
L5***RBU*N~
34+
AT8*G*L*12341.24***E*0~
35+
G61*ZZ*ZZ~
36+
L11*RBU*DP~
37+
L11*3282791-01*DJ~
38+
L11*3281272*SI~
39+
S5*2*UL*21230.12*L*0*PC*0*E~
40+
G62*70*20220824*X*0700*ED~
41+
PLD*37~
42+
NTE*TRA*HI THERE~
43+
NTE*TRA*WHATS UP~
44+
N1*ST*PUBLIX SUPER MARKETS - CHART*93*28276820017~
45+
N3*1950 SAND LAKE RD~
46+
N4*ORLANDO*FL*32809*USA~
47+
G61*DC*RECEIVING RECEIVING*TE*(941)688-4444~
48+
OID*2222228403*O2333171-01**PC*0*L*8888.88*E*0~
49+
L5***RBU*N~
50+
AT8*G*L*8888.88***E*0~
51+
G61*ZZ*ZZ~
52+
L11*RBU*DP~
53+
L11*O412323271-01*DJ~
54+
L11*4231235*SI~
55+
OID*221231238647*O222227171-01**PC*0*L*12341.24*E*0~
56+
L5***RBU*N~
57+
AT8*G*L*12341.24***E*0~
58+
G61*ZZ*ZZ~
59+
L11*RBU*DP~
60+
L11*O22321237-01*DJ~
61+
L11*42312323*SI~
62+
L3*21230.12*G***215267****0*E*0*L**00*PL~
63+
SE*61*13309~
64+
GE*1*13309~
65+
IEA*1*000013309~
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
describe "Stupidedi::TransactionSets::FortyTen::Implementations::SM204" do
2+
using Stupidedi::Refinements
3+
include TreeMatchers
4+
include NavigationMatchers
5+
6+
describe "parser" do
7+
let(:fixdir) { "004010/SM204/case" }
8+
let(:parser) { Fixtures.parse!("#{fixdir}/1.edi").head }
9+
10+
describe "parser" do
11+
let(:iea) { parser.segment.fetch }
12+
13+
it "is deterministic" do
14+
expect(parser).to be_deterministic
15+
expect(parser).to be_last
16+
end
17+
18+
it "infers separators" do
19+
expect(parser).to have_separators(
20+
:element => "*",
21+
:component => "|",
22+
:repetition => nil,
23+
:segment => "~")
24+
end
25+
end
26+
27+
describe "structure" do
28+
let(:isa) { parser.parent.fetch }
29+
30+
it "has defined sequence" do
31+
expect(parser).to have_sequence(%w(ISA GS ST B2 B2A L11 L11 L11 L11 L11 L11 G62 NTE NTE N7 S5 G62 PLD NTE NTE N1 N3 N4 G61 OID L5 AT8 G61 L11 L11 L11 OID L5 AT8 G61 L11 L11 L11 S5 G62 PLD NTE NTE N1 N3 N4 G61 OID L5 AT8 G61 L11 L11 L11 OID L5 AT8 G61 L11 L11 L11 L3 SE GE IEA))
32+
end
33+
end
34+
35+
describe "L3-05 charge" do
36+
it "is the correct 2-decimal number" do
37+
parser.first
38+
.flatmap{|m| m.find(:GS) }
39+
.flatmap{|m| m.find(:ST) }
40+
.flatmap{|m| m.find(:L3) }
41+
.tap do |m|
42+
el(m, 5) do |value|
43+
expect(value.to_f).to eq(2152.67)
44+
expect(value.to_f).not_to eq(215267)
45+
end
46+
end
47+
end
48+
49+
def el(m, *ns, &block)
50+
if Stupidedi::Either === m
51+
m.tap{|m| el(m, *ns, &block) }
52+
else
53+
yield(*ns.map{|n| m.elementn(n).map(&:value).fetch })
54+
end
55+
end
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)