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

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
#==============================================================================
# Duty or tax or fee function code qualifier                                  #
#==============================================================================
duty_or_tax_or_fee_function_code_qualifier = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..3,
  dictionary: {
    '5' => {
      description: 'Custom duty',
      identifier: 'custom_duty'
    },
    '7' => {
      description: 'Tax',
      identifier: 'tax'
    }
  },
  description: 'Duty or tax or fee function code qualifier',
  required: true
)
duty_or_tax_or_fee_function_code_qualifier.add(:duty_or_tax_or_fee_function_code_qualifier, data)

structure << duty_or_tax_or_fee_function_code_qualifier
#==============================================================================
# Duty/Tax/Fee Type                                                           #
#==============================================================================
duty_tax_fee_type = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..3,
  dictionary: {
    'ENV' => {
      description: 'Environmental tax',
      identifier: 'environmental_tax'
    },
    'GST' => {
      description: 'Goods and services tax',
      identifier: 'goods_and_services_tax'
    },
    'AAD' => {
      description: 'Tabacco tax',
      identifier: 'tabacco_tax'
    },
    'VAT' => {
      description: 'Value added tax',
      identifier: 'vat'
    },
    'IMP' => {
      description: 'Import tax',
      identifier: 'import_tax'
    },
  },
  description: 'Duty or tax or fee type name code',
  required: true
)
duty_tax_fee_type.add(:duty_or_tax_or_fee_name_code, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Code list identification code',
  required: false
)
duty_tax_fee_type.add(:code_list_identification_code_1, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..3,
  dictionary: {
    '9' => {
      description: 'EAN',
      identifier: 'ean',
    }
  },
  description: 'Code list responsible agency code',
  required: false
)
duty_tax_fee_type.add(:code_list_responsibility_agency_code_1, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..35,
  dictionary: nil,
  description: 'Duty or tax or fee type_name',
  required: false
)
duty_tax_fee_type.add(:duty_or_tax_or_fee_type_name, data)

structure << duty_tax_fee_type
#==============================================================================
# Duty/Tax/Fee Account Detail                                                 #
#==============================================================================
duty_tax_fee_account_detail = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..6,
  dictionary: nil,
  description: 'Duty or tax or fee account code',
  required: true
)
duty_tax_fee_account_detail.add(:duty_or_tax_or_fee_account_code, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Code List identifiaction code',
  required: false
)
duty_tax_fee_account_detail.add(:code_list_identification_code_2, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..3,
  dictionary: nil,
  description: 'Code list responsible agency code',
  required: false
)
duty_tax_fee_account_detail.add(:code_list_responsibility_agency_code_2, data)

structure << duty_tax_fee_account_detail
#==============================================================================
# Duty or Tax or fee assessment basis value                                   #
#==============================================================================
duty_or_tax_of_fee_assessment_basis_value = Eancom::Edifact::Composite.new()
data = Eancom::Edifact::Data.new(
  type: String,
  length: 1..15,
  dictionary: nil,
  description: 'Duty or Tax or fee assessment basis value',
  required: false
)
duty_or_tax_of_fee_assessment_basis_value.add(:duty_or_tax_of_fee_assessment_basis_value, data)

structure << duty_or_tax_of_fee_assessment_basis_value
#==============================================================================
# Duty/Tax/Fee Detail                                                         #
#==============================================================================
duty_tax_fee_detail = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..7,
  dictionary: nil,
  description: 'Duty or Tax or Fee rate code',
  required: false
)
duty_tax_fee_detail.add(:duty_tax_fee_rate_code, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Code List identifiaction code',
  required: false
)
duty_tax_fee_detail.add(:code_list_identification_code_3, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..3,
  dictionary: nil,
  description: 'Code list responsible agency code',
  required: false
)
duty_tax_fee_detail.add(:code_list_responsibility_agency_code_3, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Duty or Tax or fee rate',
  required: true
)

duty_tax_fee_detail.add(:duty_or_tax_or_fee_rate, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Duty or Tax or fee basis code',
  required: false
)
duty_tax_fee_detail.add(:duty_or_tax_or_fee_basis_code, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Duty or Tax or fee basis code',
  required: false
)
duty_tax_fee_detail.add(:duty_or_tax_or_fee_basis_code, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..17,
  dictionary: nil,
  description: 'Code List identifiaction code',
  required: false
)
duty_tax_fee_detail.add(:code_list_identification_code_4, data)

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..3,
  dictionary: nil,
  description: 'Code list responsible agency code',
  required: false
)
duty_tax_fee_detail.add(:code_list_responsibility_agency_code_4, data)

structure << duty_tax_fee_detail
#==============================================================================
# Duty or tax or fee category code
#==============================================================================
duty_or_tax_or_fee_category_code = Eancom::Edifact::Composite.new()

data = Eancom::Edifact::Data.new(
  type: String,
  length: 0..3,
  dictionary: {
    'A' => {
      description: 'Mixed tax rate',
      identifier: 'mixed_tax_rage',
    },
    'E' => {
      description: 'Exempt from tax',
      identifier: 'exempt_from_tax',
    },
    'S' => {
      description: 'Standard rate',
      identifier: 'standard_rate',
    },
  },
  description: 'Duty or tax or fee category code',
  required: false
)
duty_or_tax_or_fee_category_code.add(:duty_or_tax_or_fee_category_code, data)

structure << duty_or_tax_or_fee_category_code
#==============================================================================
Eancom.register_structure(tag: 'TAX', structure: structure)