Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def show
- @page_title = @cliente
- @imoveis = @cliente.imoveis
- @alugueis_atuais = Aluguel.atuais.all( :conditions => { :imovel_id => @imoveis.map(&:id) } )
- @imoveis_alugados = Imovel.all( :conditions => {:id => @alugueis_atuais.map(&:imovel_id)})
- @alugueis_anteriores = @cliente.alugueis
- @contas = @cliente.contas.a_vencer
- @atendimentos = @cliente.atendimentos
- @contas_imoveis_all = imobiliaria_atual.contas.all( :conditions => { :referente_id => @alugueis_atuais.map(&:id), :referente_type => 'Aluguel' } )
- @contas_imoveis = if params[:busca_de_contas].blank?
- paginate(@contas_imoveis_all)
- else
- @busca = BuscaDeContas.new( params[:busca_de_contas] )
- @busca.imobiliaria_id = imobiliaria_atual.id
- @busca.cliente_id = @cliente.id
- @busca.alugueis = @alugueis_atuais.map(&:id)
- @busca.search( :page => @page, :per_page => @per_page )
- end
- @total_projetado = @contas_imoveis_all.sum(&:valor)
- @total_real = 0
- @contas_imoveis_all.each{|conta| @total_real+=conta.valor if conta.pagamento_efetuado}
- @subtotais_reais = {:name => 'Sub-total Real: R$'}
- @subtotais_projetados = {:name => 'Sub-total Projetado: R$ '}
- @imoveis_alugados.each do |imovel|
- alugueis = Aluguel.atuais.all( :conditions => { :imovel_id => imovel.id } )
- contas = imobiliaria_atual.contas.all( :conditions => { :referente_id => alugueis.map(&:id), :referente_type => 'Aluguel' } )
- @subtotais_projetados[imovel.id] = contas.sum(&:valor)
- total_real = 0
- contas.each{|conta| total_real+=conta.valor if conta.pagamento_efetuado}
- @subtotais_reais[imovel.id] = total_real
- end
- respond_to do |format|
- format.html
- format.pdf {rghost_render :pdf,
- :report => 'export_contas',
- :filename => "#{@cliente.nome}_alugueis_#{Time.now.strftime("%d-%m-%y-%H-%M")}.pdf",
- :type => 'charset=utf-8;header=present',
- :disposition => "attachment"}
- end
Add Comment
Please, Sign In to add comment