tag = 'NAD' Eancom.register_segment(tag: tag, klass: Eancom::Edifact::NAD) structure = Eancom::Edifact::Structure.new(tag: tag) #============================================================================== # Tag # #============================================================================== tag = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 3, dictionary: nil, description: "Message Header", required: true ) tag.add(:tag, data) structure << tag #============================================================================== # Party function code qualifier # #============================================================================== party_function_code_qualifier = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..3, dictionary: { 'BY' => { description: 'Buyer', identifier: 'buyer' }, 'BO' => { description: 'Broker or sales office', identifier: 'broker_or_sales_office' }, 'BS' => { description: 'Bill and ship to', identifier: 'bill_and_ship_to' }, 'DP' => { description: 'Delivery party', identifier: 'delivery_party' }, 'DEQ' => { description: 'Shipper', identifier: 'shipper' }, 'SU' => { description: 'Supplier', identifier: 'supplier' }, 'SN' => { description: 'Store number', identifier: 'store_number' }, 'SE' => { description: 'Seller', identifier: 'seller' }, 'SR' => { description: "Supplier's agent/representative", identifier: 'suppliers_agent_representative' }, 'RB' => { description: 'Receiving financial institution', identifier: 'receiving_financial_institution' }, 'UC' => { description: 'Ultimate consignee', identifier: 'ultimate_consignee' }, 'UD' => { description: 'UD', identifier: 'Ultimate customer' }, 'MF' => { description: 'Manufacturer', identifier: 'manufacturer' }, 'MR' => { description: 'Message recipient', identifier: 'message_recipient' }, 'II' => { desription: 'Issuer of invoice', identifier: 'issuer_of_invoice' }, 'IV' => { description: 'Invoicee', identifier: 'invoicee' }, 'CO' => { description: 'Corporate officer', identifier: 'corporate_officer' }, 'GY' => { description: 'Inventory reporting party', identifier: 'inventory_reporting_party' }, 'WH' => { description: 'Warehouse keeper', identifier: 'warehouse_keeper' }, 'GO' => { description: 'Goods owner', identifier: 'goods_owner' }, 'PO' => { description: 'Ordering party', identifier: 'ordering_party' }, 'PE' => { description: 'Payee', identifier: 'payee' }, 'CN' => { description: 'Consignee', identifier: 'consignee' }, 'X52' => { description: 'Breeder (GS1 Temporary Code)', identifier: 'breeder' } }, description: "Party function code qualifier", required: true ) party_function_code_qualifier.add(:party_function_code_qualifier, data) structure << party_function_code_qualifier #============================================================================== # Party Identification details # #============================================================================== party_identification_details = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: "GLN - Format n13\nFor identification of parties it is recommended to use GLN - Format n13", required: true ) party_identification_details.add(:party_identifier, data) data = Eancom::Edifact::Data.new( type: String, length: 0..17, dictionary: nil, description: 'Code list identification code', required: false ) party_identification_details.add(:code_list_identification_code_1, data) data = Eancom::Edifact::Data.new( type: String, length: 1..3, dictionary: { '9' => { description: 'GS1', identifier: 'gs1' } }, description: 'Code list responsible agency code (9 = GS1)', required: true ) party_identification_details.add(:code_list_responsible_agency_code_1, data) structure << party_identification_details #============================================================================== # Name and Address # #============================================================================== name_address = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: 'Name and address description', required: true ) name_address.add(:name_and_address_description_1, data) name_address.add(:name_and_address_description_2, data) name_address.add(:name_and_address_description_3, data) name_address.add(:name_and_address_description_4, data) name_address.add(:name_and_address_description_5, data) structure << name_address #============================================================================== # Party Name # #============================================================================== party_name = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: 'Party Name', required: true ) party_name.add(:party_name_1, data) party_name.add(:party_name_2, data) party_name.add(:party_name_3, data) party_name.add(:party_name_4, data) party_name.add(:party_name_5, data) structure << party_name #============================================================================== # Street # #============================================================================== street = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: 'Street and number or post office box identifier', required: true ) street.add(:street_and_number_1, data) street.add(:street_and_number_2, data) street.add(:street_and_number_3, data) street.add(:street_and_number_4, data) street.add(:street_and_number_5, data) structure << street #============================================================================== # City name # #============================================================================== city_name = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: 'City/Town, clear text', required: false ) city_name.add(:city_name, data) structure << city_name #============================================================================== # Country Sub-Entity details # #============================================================================== country_sub_entity_details = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..9, dictionary: nil, description: 'Country sub-entity name code', required: false ) country_sub_entity_details.add(:country_sub_entity_name_code, data) data = Eancom::Edifact::Data.new( type: String, length: 1..17, dictionary: nil, description: 'Code list identification code', required: false ) country_sub_entity_details.add(:code_list_identification_code_2, data) data = Eancom::Edifact::Data.new( type: String, length: 1..3, dictionary: nil, description: 'Code list responsible agency code', required: false ) country_sub_entity_details.add(:code_list_responsible_agency_code_2, data) data = Eancom::Edifact::Data.new( type: String, length: 1..70, dictionary: nil, description: 'Country sub-entry name', required: false ) country_sub_entity_details.add(:country_sub_entry_name, data) structure << country_sub_entity_details #============================================================================== # Postal Identification Code # #============================================================================== postal_identification_code = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..17, dictionary: nil, description: 'Postal identification code', required: false ) postal_identification_code.add(:postal_identification_code, data) structure << postal_identification_code #============================================================================== # Country Name Code # #============================================================================== country_name_code = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..3, dictionary: nil, description: 'ISO 3166 two alpha code', required: false ) country_name_code.add(:country_name_code, data) structure << country_name_code #============================================================================== Eancom.register_structure(tag: 'NAD', structure: structure)