Skip to content

Commit

Permalink
Adiciona aluguel formatado aos detalhe da fatura.
Browse files Browse the repository at this point in the history
Co-authored-by: Vinícius Peruzzi <[email protected]>
  • Loading branch information
angelomaia and Vinigperuzzi committed Jul 21, 2024
1 parent 55d9fbc commit d417604
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/bill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def total_value_formatted
"R$ #{format('%.2f', total_value_cents / 100.0).gsub('.', ',')}"
end

def rent_fee_value_formatted
return "R$ #{format('%.2f', values['rent_fee_cents'] / 100.0).gsub('.', ',')}" if values['rent_fee_cents'].positive?

false
end

def self.format_value(value)
"R$ #{format('%.2f', value / 100.0).gsub('.', ',')}"
end
Expand Down
6 changes: 6 additions & 0 deletions app/views/bills/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<td><%= Bill.format_value detail['value_cents'] %></td>
</tr>
<% end %>
<% if @bill.rent_fee_value_formatted %>
<tr>
<td> Aluguel </td>
<td> <%= @bill.rent_fee_value_formatted %>
</tr>
<% end%>
<tr>
<td><strong>Total</strong></td>
<td><strong><%= @bill.total_value_formatted %></strong></td>
Expand Down

0 comments on commit d417604

Please sign in to comment.