Skip to content

Commit

Permalink
add 4010 810 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
kelnadim committed Dec 16, 2021
1 parent fbf40e8 commit ee1be1c
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 54 deletions.
68 changes: 29 additions & 39 deletions lib/stupidedi/transaction_sets/004010/implementations/IN810.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ module Implementations
b::Element(e::Situational, "Transaction Set Purpose Code"),
b::Element(e::Situational, "Action Code"),
b::Element(e::Situational, "Invoice Number")),
b::Segment(30, s:: REF, "Reference Identification", r::Situational, d::RepeatCount.unbounded,
b::Element(e::Required, "Reference Identification Qualifier"),
b::Element(e::Situational, "Reference Identification"),
b::Element(e::Situational, "Description"),
b::Element(e::Situational, "Description")),
d::LoopDef.build("N1", d::RepeatCount.bounded(200),
b::Segment(110, s:: N1, "Name", r::Situational, d::RepeatCount.bounded(1),
b::Element(e::Required, "Entity Identifier Code"),
Expand Down Expand Up @@ -114,12 +109,7 @@ module Implementations
b::Element(e::Situational, "Surface/Layer/Position Code"),
b::Element(e::Situational, "Source Subqualifier"),
b::Element(e::Situational, "Yes/No Condition or Response Code"),
b::Element(e::Situational, "Language Code"))), #end LoopDef PID, Segment 30
b::Segment(40, s:: REF, "Reference Identification", r::Situational, d::RepeatCount.unbounded,
b::Element(e::Required, "Reference Identification Qualifier"),
b::Element(e::Situational, "Reference Identification"),
b::Element(e::Situational, "Description"),
b::Element(e::Situational, "Description")))), #end TableDef Detail, LoopDef IT1
b::Element(e::Situational, "Language Code"))))), #end TableDef Detail, LoopDef IT1, LoopDef PID, Segment 30
d::TableDef.header("Summary",
b::Segment(10, s::TDS, "Total Monetary Value Summary", r::Required, d::RepeatCount.bounded(1),
b::Element(e::Situational, "Amount"),
Expand All @@ -137,35 +127,35 @@ module Implementations
b::Element(e::Situational, "Dollar Basis For Percent"),
b::Element(e::Situational, "Tax Identification Number"),
b::Element(e::Situational, "Assigned Identification")), #end Segment 20
d::LoopDef.build("SAC", d::RepeatCount.bounded(25),
b::Segment(30, s::SAC, "Service, Promotion, Allowance, or Charge Information", r::Situational, d::RepeatCount.bounded(1),
b::Element(e::Situational, "Allowance or Charge Indicator"),
b::Element(e::Situational, "Service, Promotion, Allowance, or Charge Code"),
b::Element(e::Situational, "Agency Qualifier Code"),
b::Element(e::Situational, "Agency Service, Promotion, Allowance, or Charge Code"),
b::Element(e::Situational, "Amount"),
b::Element(e::Situational, "Allowance/Charge Percent Qualifier"),
b::Element(e::Situational, "Percent"),
b::Element(e::Situational, "Rate"),
d::LoopDef.build("SAC", d::RepeatCount.bounded(25),
b::Segment(30, s::SAC, "Service, Promotion, Allowance, or Charge Information", r::Situational, d::RepeatCount.bounded(1),
b::Element(e::Situational, "Allowance or Charge Indicator"),
b::Element(e::Situational, "Service, Promotion, Allowance, or Charge Code"),
b::Element(e::Situational, "Agency Qualifier Code"),
b::Element(e::Situational, "Agency Service, Promotion, Allowance, or Charge Code"),
b::Element(e::Situational, "Amount"),
b::Element(e::Situational, "Allowance/Charge Percent Qualifier"),
b::Element(e::Situational, "Percent"),
b::Element(e::Situational, "Rate"),
b::Element(e::Situational, "Unit or Basis for Measurement Code"),
b::Element(e::Situational, "Quantity"),
b::Element(e::Situational, "Quantity"),
b::Element(e::Situational, "Allowance or Charge Method of Handling Code"),
b::Element(e::Situational, "Reference Identification"),
b::Element(e::Situational, "Option Number"),
b::Element(e::Situational, "Description"),
b::Element(e::Situational, "Language Code"))), #end LoopDef SAC, Segment 30
b::Segment(40, s::CTT, "Transaction Totals", r::Situational, d::RepeatCount.bounded(10),
b::Element(e::Situational, "Number of Line Items"),
b::Element(e::Situational, "Hash Total"),
b::Element(e::Situational, "Weight"),
b::Element(e::Situational, "Unit or Basis for Measurement Code"),
b::Element(e::Situational, "Quantity"),
b::Element(e::Situational, "Quantity"),
b::Element(e::Situational, "Allowance or Charge Method of Handling Code"),
b::Element(e::Situational, "Reference Identification"),
b::Element(e::Situational, "Option Number"),
b::Element(e::Situational, "Description"),
b::Element(e::Situational, "Language Code"))), #end LoopDef SAC, Segment 30
b::Segment(40, s::CTT, "Transaction Totals", r::Situational, d::RepeatCount.bounded(10),
b::Element(e::Situational, "Number of Line Items"),
b::Element(e::Situational, "Hash Total"),
b::Element(e::Situational, "Weight"),
b::Element(e::Situational, "Unit or Basis for Measurement Code"),
b::Element(e::Situational, "Volume"),
b::Element(e::Situational, "Unit or Basis for Measurement Code"),
b::Element(e::Situational, "Description")), #end Segment 40
b::Segment(50, s:: SE, "Transaction Set Trailer", r::Required, d::RepeatCount.bounded(1),
b::Element(e::Required, "Number of Included Segments"),
b::Element(e::Required, "Transaction Set Control Number")))) #end build IN, TableDef Summary, Segment 50
b::Element(e::Situational, "Volume"),
b::Element(e::Situational, "Unit or Basis for Measurement Code"),
b::Element(e::Situational, "Description")), #end Segment 40
b::Segment(50, s:: SE, "Transaction Set Trailer", r::Required, d::RepeatCount.bounded(1),
b::Element(e::Required, "Number of Included Segments"),
b::Element(e::Required, "Transaction Set Control Number")))) #end build IN, TableDef Summary, Segment 50
end
end
end
Expand Down
32 changes: 17 additions & 15 deletions spec/fixtures/004010/IN810/pass/1.edi
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
ISA*00*810BK4010 *00* *ZZ*111111 *ZZ*2222222 *211216*0252*U*00401*005626765*0*P*>~
GS*IN*111111*2222222*20211216*0252*5626765*X*004010~
ST*810*5626765~
BIG*20211216*00232917*20211026*1376-0010391~
N1*ST*Store Shipping Address*ZZ*8025886~
N3*123 address_1*address_2~
N4*Huntington*IN*46750~
ITD**3*****30~
IT1**1**5.32****EN*9780618872657*GC*02~
PID*F****Native Guard~
TDS*532~
CTT*1*1~
SE*11*5626765~
GE*1*5626765~
IEA*1*005626765~
ISA|00|810BK4010 |00| |ZZ|111111 |ZZ|2222222 |211118|0752|U|00401|005639689|0|T|>~
GS|IN|111111|2222222|20211118|0752|5639689|X|004010~
ST|810|5639689~
BIG|20211118|00237058|20211102|0691-0014403~
N1|ST|Store Shipping Address|ZZ|1091581~
N3|123 address_1|address_2~
N4|SAVANNAH|GA|314014245~
ITD||3|||||30~
IT1||4||70||||EN|9781501331978|GC|01~
PID|F||||Retail Buying From Basics to Fashion~
IT1||1||5.66||||EN|9780316154680|GC|02~
PID|F||||When You Are Engulfed in Flames~
TDS|28566~
CTT|2|5~
SE|13|5639689~
GE|1|5639689~
IEA|1|005639689~
76 changes: 76 additions & 0 deletions spec/lib/stupidedi/transaction_sets/004010/IN810_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
describe "Stupidedi::TransactionSets::FortyTen::Implementations::IN810" do
using Stupidedi::Refinements
include TreeMatchers
include NavigationMatchers

describe "parser" do
let(:fixdir) { "004010/IN810/pass" }
let(:parser) { Fixtures.parse!("#{fixdir}/1.edi").head }

describe "parser" do
let(:iea) { parser.segment.fetch }

it "is deterministic" do
expect(parser).to be_deterministic
expect(parser).to be_last
end

it "infers separators" do
expect(parser).to have_separators(
:element => "|",
:component => ">",
:repetition => nil,
:segment => "~")
end
end

describe "structure" do
let(:isa) { parser.parent.fetch }

it "has defined sequence" do
expect(parser).to have_sequence(%w(ISA GS ST BIG N1 N3 N4 ITD IT1 PID IT1 PID TDS CTT SE GE IEA))
end

it "is correct" do
expect(isa).to have_distance(16).to(parser)
expect(isa).to have_structure(
Ss(X(:ST),
R(:ISA),
# GS|IN|111111|2222222|20211118|0752|5639689|X|004010~
S(:GS, "IN", "111111", "2222222", "20211118", "0752", "5639689", "X", "004010") =>
Ss(R(:GS),
# ST|810|5639689~
S(:ST, "810", "5639689") =>
Ss(R(:ST),
# BIG|20211118|00237058|20211102|0691-0014403~
S(:BIG, "20211118", "00237058", "20211102", "0691-0014403"),
# N1|ST|Store Shipping Address|ZZ|1091581~
S(:N1, "ST", "Store Shipping Address", "ZZ", "1091581") => Ss(
# N3|123 address_1|address_2~
S(:N3, "123 address_1", "address_2") => Ss(
# N4|SAVANNAH|GA|314014245~
S(:N4, "SAVANNAH", "GA", "314014245") => Ss())),
# ITD||3|||||30~
S(:ITD, "", "3", "", "", "", "", "30") => Ss(),
# IT1||4||70||||EN|9781501331978|GC|01~
S(:IT1, "", "", "", "70", "", "", "", "EN", "9781501331978", "GC", "01") => Ss(
# PID|F||||Retail Buying From Basics to Fashion~
S(:PID, "F", "", "", "", "Retail Buying From Basics to Fashion") => Ss()),
# IT1||1||5.66||||EN|9780316154680|GC|02~
S(:IT1, "", "1", "", "5.66", "", "", "", "EN", "9780316154680", "GC", "02") => Ss(
# PID|F||||When You Are Engulfed in Flames~
S(:PID, "F", "", "", "", "When You Are Engulfed in Flames") => Ss()),
# TDS|28566~
S(:TDS, "28566") => Ss(
# CTT|2|5~
S(:CTT, "2", "5") => Ss(
# SE|13|5639689~
S(:SE, "13", "5639689") => Ss()))),
# GE|1|5639689~
S(:GE, "1", "5639689") => Ss(S(:IEA)),
# IEA|1|005639689~
S(:IEA, "1", "005639689") => Ss())))
end
end
end
end

0 comments on commit ee1be1c

Please sign in to comment.