﻿population_transfer_try_execute = {
    save_scope_as = population_transfer_receiver_country_scope

    if = {
        limit = {
            has_variable = population_transfer_source_state
            has_variable = population_transfer_target_state
            has_variable = population_transfer_quantity
        }

        var:population_transfer_target_state = {
            save_scope_as = population_transfer_target_state_scope
        }

        var:population_transfer_source_state = {
            every_scope_pop = {
                move_partial_pop = {
                    state = scope:population_transfer_target_state_scope
                    population_ratio = {
                        value = scope:population_transfer_receiver_country_scope.var:population_transfer_quantity
                        divide = 100
                    }
                }
            }
        }

        remove_variable = population_transfer_source_state
        remove_variable = population_transfer_target_state
        remove_variable = population_transfer_quantity
    }
}
