# frozen_string_literal: true
module Stupidedi
  module TransactionSets
    module FortyTen
      module Implementations
        b = Builder
        d = Schema
        r = SegmentReqs
        e = ElementReqs
        s = SegmentDefs

        SS862 = b.build("SS", "862", "",
          d::TableDef.header("Header",
            b::Segment(10, s:: ST, "Transaction Set Header", r::Required, d::RepeatCount.bounded(1),
              b::Element(e::Required,    "Transaction Set Identifier Code", b::Values("862")),
              b::Element(e::Required,    "Transaction Set Control Number")),
            b::Segment(20, s::BSS, "Beginning Segment for Shipping Schedule/Production Sequence", r::Required, d::RepeatCount.bounded(1),
              b::Element(e::Required,    "Transaction Set Purpose Code", b::Values("00","01","05")),
              b::Element(e::Required,    "Reference Identification - Ship Schedule Number"),
              b::Element(e::Required,    "Date - Create date for this transaction"),
              b::Element(e::Required,    "Schedule Type Qualifier", b::Values("SH")),
              b::Element(e::Required,    "Date - Horizon Start"),
              b::Element(e::Required,    "Date - Horizon End"),
              b::Element(e::NotUsed,     ""),
              b::Element(e::Situational, "Reference Identification"),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::Situational, "Schedule Quantity Qualifier", b::Values("A"))),
            b::Segment(30, s::DTM, "Date/Time Reference", r::Situational, d::RepeatCount.bounded(10),
              b::Element(e::Required,    "Date/Time Qualifier", b::Values("193","194")),
              b::Element(e::Situational, "Date"),
              b::Element(e::Situational, "Time - Window Start/ Stop"),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     "")),

            d::LoopDef.build("N1", d::RepeatCount.bounded(200),
              b::Segment(50, s:: N1, "Name", r::Situational, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Entity Identifier Code", b::Values("MI", "SI", "SU")),
                b::Element(e::Situational, "Name"),
                b::Element(e::Situational, "Identification Code Qualifier", b::Values("2","92")),
                b::Element(e::Situational, "Identification Code"),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     "")),
              b::Segment(90, s::REF,  "Reference Identification", r::Situational, d::RepeatCount.bounded(12),
                b::Element(e::Required,    "Reference Identification Qualifier", b::Values("P8", "PE", "RG","RU","SI")),
                b::Element(e::Situational, "Reference Identification"),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     "")),
              b::Segment(100, s::PER, "Administrative Communications Contact", r::Situational, d::RepeatCount.bounded(3),
                b::Element(e::Required,    "Contact Function Code", b::Values("CN")),
                b::Element(e::Situational, "Name - NNA Logistics Contact"),
                b::Element(e::Situational, "Communication Number Qualifier", b::Values("TE")),
                b::Element(e::Situational, "Communication Number - Phone Number"),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     "")))),

          d::TableDef.header("Detail",
            d::LoopDef.build("LIN", d::RepeatCount.bounded(10000),
              b::Segment( 10, s::LIN, "Item Identification", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Situational, "Assigned Identification LINE Number"),
                b::Element(e::Required,    "Product/Service ID Qualifier", b::Values("BP")),
                b::Element(e::Required,    "Product/Service ID - NNA Part Number"),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     "")),
              b::Segment( 20, s::UIT, "Unit Detail - Detail 1", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Composite Unit of Measure",
                b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("PC")),
                b::Element(e::NotUsed,     "Exponent"),
                b::Element(e::NotUsed,     "Multiplier"),
                b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("LB")),
                b::Element(e::NotUsed,     "Exponent"),
                b::Element(e::Situational, "Multiplier")),
                b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("EA"))),
              b::Segment(50, s::REF, "Reference Identification", r::Situational, d::RepeatCount.bounded(12),
                b::Element(e::Required,    "Reference Identification Qualifier", b::Values("DK","LU","P5")),
                b::Element(e::Situational, "Reference Identification"),
                b::Element(e::NotUsed,     ""),
                b::Element(e::NotUsed,     "")),

              d::LoopDef.build("FST", d::RepeatCount.bounded(100),
                b::Segment( 80, s::FST, "Forecast Schedule", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Quantity - RAN Quantity"),
                  b::Element(e::Required,    "Forecast Qualifier", b::Values("C")),
                  b::Element(e::Required,    "Forecast Timing Qualifier", b::Values("D")),
                  b::Element(e::Required,    "Date - Ship Date"),
                  b::Element(e::NotUsed,     ""),
                  b::Element(e::Situational, "Date/Time Qualifier"),
                  b::Element(e::Situational, "Time - of Shipment"),
                  b::Element(e::Situational, "Reference Number Qualifier", b::Values("DO")),
                  b::Element(e::Situational, "Reference Number - RAN Number")),

                d::LoopDef.build("JIT", d::RepeatCount.bounded(96),
                  b::Segment( 110, s::JIT, "Just-In-Time Schedule", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Quantity - QTY to be picked up"),
                    b::Element(e::Required,    "Time - Pick up Time")),
                  b::Segment( 120, s::REF,  "Reference Identification", r::Situational, d::RepeatCount.bounded(500),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("P5")),
                    b::Element(e::Situational, "Reference Identification - Position in Truck"),
                    b::Element(e::NotUsed,     ""),
                    b::Element(e::Situational, "Reference Identifier",
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("DO")),
                    b::Element(e::Required,    "Reference Identification RAN Number"),
                    b::Element(e::Situational, "Reference Identification Qualifier", b::Values("LU")),
                    b::Element(e::Situational, "Reference Identification - Receiving Location"),
                    b::Element(e::Situational, "Reference Identification Qualifier", b::Values("DK")),
                    b::Element(e::Situational, "Reference Identification - Dock Number"))))))),

          d::TableDef.header("Summary",
            b::Segment(10, s::CTT, "Transaction Totals", r::Situational, d::RepeatCount.bounded(1),
              b::Element(e::Required,    "Number of Units Shipped"),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     ""),
              b::Element(e::NotUsed,     "")),
            b::Segment(30, 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
    end
  end
end
