FactoryBot.define do
	factory :convenio0001, class: 'Contabilidade::Convenio' do
		numero {1}
		data_da_celebracao {"2016-09-06"}
		inicio_da_vigencia {"2016-09-06"}
		fim_da_vigencia {"2017-09-05"}
		valor_do_repasse {1200000.00}
		valor_da_contrapartida {12000.00}
		cedente {"CDXC"}
		modalidade {'concedido'}

		tipo_de_transferencia_id {
			Base::TipoDeTransferencia.find_or_create_by!( FactoryBot.attributes_for( :municipais_concedidas ) ).id
		}

		tipo_de_esfera_id {
			Base::TipoDeEsfera.find_or_create_by!( FactoryBot.attributes_for( :tipo_de_esfera, :orcamento_2016 ) ).id
		}

		receita_corrente_id {
			Base::NaturezaDaReceita.find_or_create_by( FactoryBot.attributes_for( :nova_natureza_receita_corrente, :novo_tipo, de_convenio: true ) ).try(:id)
		}

		receita_de_capital_id {
			Base::NaturezaDaReceita.find_or_create_by( FactoryBot.attributes_for( :nova_natureza_receita_capital, :novo_tipo, de_convenio: true ) ).try(:id)
		}

		funcao_id {
			Base::Funcao.find_or_create_by!( FactoryBot.attributes_for( :funcao_saude, :orcamento_2016 ) ).id
		}

		orcamento_id {
			Orcamento.find_or_create_by!( FactoryBot.attributes_for( :orcamento_2016 ) ).id
		}

		unidade_orcamentaria_id {
			Loa::UnidadeOrcamentaria.find_or_create_by!( FactoryBot.attributes_for(:loa_hgf, :orcamento_2017)).id
		}

		after(:build) {
			Base::TipoDeDespesa.find_or_create_by!( FactoryBot.attributes_for( :despesa_corrente ) )
			Base::TipoDeDespesa.find_or_create_by!( FactoryBot.attributes_for( :despesa_de_capital ) )
		}
	end
end
