From ee1be1c95f03ee2878965d58943126535c3c5743 Mon Sep 17 00:00:00 2001 From: Karim Elnadim Date: Thu, 16 Dec 2021 14:01:29 -0600 Subject: [PATCH] add 4010 810 spec --- .../004010/implementations/IN810.rb | 68 +++++++---------- spec/fixtures/004010/IN810/pass/1.edi | 32 ++++---- .../transaction_sets/004010/IN810_spec.rb | 76 +++++++++++++++++++ 3 files changed, 122 insertions(+), 54 deletions(-) create mode 100644 spec/lib/stupidedi/transaction_sets/004010/IN810_spec.rb diff --git a/lib/stupidedi/transaction_sets/004010/implementations/IN810.rb b/lib/stupidedi/transaction_sets/004010/implementations/IN810.rb index e3c3334c8..2fedae383 100644 --- a/lib/stupidedi/transaction_sets/004010/implementations/IN810.rb +++ b/lib/stupidedi/transaction_sets/004010/implementations/IN810.rb @@ -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"), @@ -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"), @@ -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 diff --git a/spec/fixtures/004010/IN810/pass/1.edi b/spec/fixtures/004010/IN810/pass/1.edi index 86c8e8937..29c534ee7 100644 --- a/spec/fixtures/004010/IN810/pass/1.edi +++ b/spec/fixtures/004010/IN810/pass/1.edi @@ -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~ diff --git a/spec/lib/stupidedi/transaction_sets/004010/IN810_spec.rb b/spec/lib/stupidedi/transaction_sets/004010/IN810_spec.rb new file mode 100644 index 000000000..d1306bc5d --- /dev/null +++ b/spec/lib/stupidedi/transaction_sets/004010/IN810_spec.rb @@ -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