Itens da Forma de Pagamento

<% @forma_pagamento_items = FormaPagamentoItem.find_by_sql ["SELECT id, forma_pagamento_id, tipo_pagamento_id, percentual, dias FROM forma_pagamento_items WHERE forma_pagamento_id = ?", params[:id]] @percentual_total = FormaPagamentoItem.find_by_sql ["SELECT sum(percentual) as soma FROM forma_pagamento_items WHERE forma_pagamento_id = ?", params[:id]] %> <% if @forma_pagamento_items != nil then %> <% odd_or_even = 0 ; for forma_pagamento_item in @forma_pagamento_items ; odd_or_even = 1 - odd_or_even %> <% objTipoPagamento = TipoPagamento.find(forma_pagamento_item.tipo_pagamento_id) %> <% end %> <% end %> <% if @percentual_total[0].soma != '100' then %>
Tipo de Pagamento Percentual Dias Apagar
<%= link_to objTipoPagamento.descricao, objTipoPagamento %> <%= h number_to_percentage(forma_pagamento_item.percentual, {:precision => 2, :separator => ","}) %> <%= h forma_pagamento_item.dias %> <%= link_to (image_tag('excluir.gif', :class => 'icon')), forma_pagamento_item, :confirm => 'Confirma exclusão deste item?', :method => :delete %>
Percentual Total <% end %> <% if @percentual_total[0].soma == '100' then %> <% end %> <%= @percentual_total[0].soma %>%