FactoryBot.define do
  factory :gestao_de_estoque_movimentacao_do_estoque, class: 'GestaoDeEstoque::MovimentacaoDoEstoque' do
    estoque_id { GestaoDeEstoque::Estoque.find_or_create_by!(FactoryBot.attributes_for(:gestao_de_estoque_estoque)).id }
    unidade_orcamentaria_id { Loa::UnidadeOrcamentaria.find_or_create_by!(FactoryBot.attributes_for(:loa_hgf, :orcamento_2016)).id }
    almoxarifado_id { FactoryBot.create(:gestao_de_estoque_almoxarifado).id }
    orcamento_id { Orcamento.find_or_create_by!(FactoryBot.attributes_for(:orcamento_2017)).id }
    valor_unitario { 12.20 }
    valor_total { 1830 }

    trait :entrada do
      origem_id { GestaoDeEstoque::RecebimentoDeMaterial.find_or_create_by!(FactoryBot.attributes_for(:gestao_de_estoque_recebimento_de_material, almoxarifado_id: almoxarifado_id)).id }
      origem_type { 'GestaoDeEstoque::RecebimentoDeMaterial' }
      quantidade_entrada { 150 }
    end

    trait :saida do
      origem_id { Administrativo::RequisicaoDeMaterial.find_or_create_by!(FactoryBot.attributes_for(:administrativo_requisicao_de_material)).id }
      origem_type { 'Administrativo::RequisicaoDeMaterial' }
      quantidade_saida { 80 }
    end
  end
end
