code: def report_on_field(layer):
      
      source_fields = layer.keywords['inasafe_fields']
      if source_fields.get(size_field['key']):
          field_size = source_fields[size_field['key']]
          field_index = layer.fields().lookupField(field_size)
      else:
          field_index = None
  
      # Special case for a point layer and indivisible polygon,
      # we do not want to report on the size.
      geometry = layer.geometryType()
      exposure = layer.keywords.get('exposure')
      if geometry == QgsWkbTypes.PointGeometry:
          field_index = None
      if geometry == QgsWkbTypes.PolygonGeometry and exposure == \
              exposure_structure['key']:
          field_index = None
  
      # Special case if it's an exposure without classification. It means it's
      # a continuous exposure. We count the compulsory field.
      classification = layer.keywords.get('classification')
      if not classification:
          exposure_definitions = definition(exposure)
          # I take the only first field for reporting, I don't know how to manage
          # with many fields. AFAIK we don't have this case yet.
          field = exposure_definitions['compulsory_fields'][0]
          field_name = source_fields[field['key']]
          field_index = layer.fields().lookupField(field_name)
  
      return field_index
docs: Helper function to set on which field we are going to report.
  
      The return might be empty if we don't report on a field.
  
      :param layer: The vector layer.
      :type layer: QgsVectorLayer
  
      :return: The field index on which we should report.
      :rtype: int