tag = 'CNT'
Eancom.register_segment(tag: tag, klass: Eancom::Edifact::CNT)

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
#==============================================================================
# Controle                                                                    #
#==============================================================================
control = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..3,
  dictionary: {
    '1' => {
      description: 'Total value of the quantity segments at line level in a message',
      identifier: 'total_value'
    },
    '2' => {
      description: 'Number of line items in message',
      identifier: 'total_line_items'
    },
    '3' => {
      description: 'Number of line and sub items in message',
      identifier: 'number_of_line_and_sub_items_in_message'
    },
    '7' => {
      description: 'Total gross weight',
      identifier: 'total_gross_weight'
    },
    '11' => {
      description: 'Total number of packages',
      identifier: 'total_number_packages'
    },
    '26' => {
      description: 'Total gross measurment/cube',
      identifier: 'total_gross_measurement'
    },
    '29' => {
      description: 'Total net weight of consigmnet',
      identifier: 'total_net_weight'
    }
  },
  description: "control total type code quantifier",
  required: true
)
control.add(:control_total_type_code_quantifier, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..18,
  dictionary: nil,
  description: "Control total value",
  required: true
)
control.add(:control_total_value, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..3,
  dictionary: nil,
  description: "Measurment unit code",
  required: false
)
control.add(:measurment_unit_code, data)

structure << control
#==============================================================================
Eancom.register_structure(tag: 'CNT', structure: structure)