id: vnf_projects
migration_group: vnf
label: 'Projects migration'
source:
  plugin: csv
  path: modules/custom/vnf_migrate/projekti.csv
  ids: [id]
  delimiter: ;
  constants:
    uid: 2
process:
  type:
    plugin: default_value
    default_value: project
  title: Projekts
  field_project_competition_id: Konkursa ID
  field_project_applicant_name: applicant
  field_project_applicant_type:
    plugin: entity_generate
    source: Statuss
    value_key: name
    bundle: organisation_types
    entity_type: taxonomy_term
    ignore_case: true

  field_project_contact_name: Kontaktpersona
  field_project_contact_phone: Talrunis
  field_project_contact_email: E-pasts

  field_project_dates/value:
    plugin: format_date
    source: Sakuma datums
    from_format: n/j/Y
    to_format: Y-m-d
  field_project_dates/end_value:
    plugin: format_date
    source: beigu datums
    from_format: n/j/Y
    to_format: Y-m-d

  field_district:
    plugin: entity_generate
    source: district
    value_key: name
    bundle: regions
    entity_type: taxonomy_term
    ignore_case: true

  field_project_amount_requested: requested
  field_project_amount_approved: approved
  field_project_amount_used: used

  field_project_decision_date:
    plugin: format_date
    source: decision date
    from_format: n/j/Y
    to_format: Y-m-d
  field_project_contract_date:
    plugin: format_date
    source: contract date
    from_format: n/j/Y
    to_format: Y-m-d

  field_project_reg_nr: reg nr
  field_project_address: adrese
  field_project_signatory: signatory
  field_project_signatory_position: signatory position
  field_project_bank_account: bank account

  field_bank:
    plugin: entity_generate
    source: bank
    value_key: name
    bundle: banks
    entity_type: taxonomy_term
    ignore_case: true

  field_project_area_affected:
    -
      plugin: explode
      source: area
      delimiter: ', '
    -
      plugin: entity_generate
      value_key: name
      bundle: regions
      entity_type: taxonomy_term
      ignore_case: true

  created:
    plugin: format_date
    source: Sakuma datums
    from_format: n/j/Y
    to_format: U
  uid: constants/uid
destination:
  plugin: 'entity:node'
migration_dependencies:
  required: {  }
  optional: {  }
