Last active
July 2, 2020 15:47
-
-
Save edivandecastro/b732fbea431d2c1fbfa327962f97a72f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def execute | |
@movements.each do |movement| | |
spu_movement = Activity::SpuMovement.find_or_initialize_by(code: movement["id"], procedure_id: @procedure.id) | |
next if spu_movement.persisted? | |
original_individual_id = @procedure.individual_id | |
progress = create_progress_with_virtual_assistant(@procedure) | |
spu_movement.assign_attributes( | |
action: movement["procedimento"], | |
responsible: movement["responsavel"], | |
execution_date: movement["data"], | |
origin_code: movement["lotacao_origem_id"], | |
origin: movement["lotacao_origem"], | |
destination_code: movement["lotacao_destino_id"], | |
destination: movement["lotacao_destino"], | |
progress_id: progress.id | |
) | |
spu_movement.documents = movement["files"].map do |file| | |
Shared::Document.new( | |
owner: spu_movement, | |
document: file, | |
document_type: Activity::SpuMovement.document_types[:judicial_order], | |
original_filename: file.original_filename | |
) | |
end | |
if spu_movement.save | |
progress.finish_progress_in_activity(spu_movement) | |
@procedure.update_attribute(:individual_id, original_individual_id) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment