tag = 'ALI' Eancom.register_segment(tag: tag, klass: Eancom::Edifact::ALI) 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 #============================================================================== # Country of origin name code # #============================================================================== country_of_origin_name_code = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 0..3, dictionary: nil, description: 'Use ISO 3366 two alpha', required: false ) country_of_origin_name_code.add(:country_of_origin_name_code, data) structure << country_of_origin_name_code #============================================================================== # Duty regime type code # #============================================================================== duty_regime_type_code = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 0..3, dictionary: nil, description: 'Duty regime type code', required: false ) duty_regime_type_code.add(:duty_regime_type_code, data) structure << duty_regime_type_code #============================================================================== # Special condition code # #============================================================================== special_condition_code = Eancom::Edifact::Composite.new() dict = { '6' => { description: 'Subject to bonus', identifier: 'subject_to_bonus' }, '8' => { description: 'Subject to discount', identifier: 'subject_to_discount', }, } data = Eancom::Edifact::Data.new( type: String, length: 0..3, dictionary: dict, description: 'Special Condition Code', required: false ) special_condition_code.add(:special_condition_code_1, data) structure << special_condition_code special_condition_code = Eancom::Edifact::Composite.new() special_condition_code.add(:special_condition_code_2, data) structure << special_condition_code special_condition_code = Eancom::Edifact::Composite.new() special_condition_code.add(:special_condition_code_3, data) structure << special_condition_code special_condition_code = Eancom::Edifact::Composite.new() special_condition_code.add(:special_condition_code_4, data) structure << special_condition_code special_condition_code = Eancom::Edifact::Composite.new() special_condition_code.add(:special_condition_code_5, data) structure << special_condition_code #============================================================================== Eancom.register_structure(tag: 'ALI', structure: structure)