diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 52decd4b..f343451b 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -521,3 +521,11 @@ i.package.icon-only { padding: 15px; padding-bottom: 0px; } + +span.positive_amount { + color: black; +} + +span.negative_amout { + color: red; +} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e8de97e0..5282841d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,6 +19,11 @@ module ApplicationHelper I18n.l(time, :format => format) unless (time.nil? || format.nil?) end + def format_currency(amount) + class_name = amount < 0 ? 'negative_amout' : 'positive_amount' + content_tag :span, number_to_currency(amount), class: class_name + end + # Creates ajax-controlled-links for pagination def pagination_links_remote(collection, options = {}) per_page = options[:per_page] || @per_page diff --git a/app/views/finance/financial_links/show.html.haml b/app/views/finance/financial_links/show.html.haml index c4227ce0..0b51cb2b 100644 --- a/app/views/finance/financial_links/show.html.haml +++ b/app/views/finance/financial_links/show.html.haml @@ -17,7 +17,7 @@ = format_date item[:date] %td= item[:type] %td= item[:description] - %td.currency{:style => "color:#{item[:amount] < 0 ? 'red' : 'black'}; width:5em"}= number_to_currency(item[:amount]) + %td.numeric{style: 'width:5em'}= format_currency item[:amount] %p = @financial_link.note diff --git a/app/views/finance/financial_transactions/_transactions.html.haml b/app/views/finance/financial_transactions/_transactions.html.haml index 0bdd95bb..dc99f65f 100644 --- a/app/views/finance/financial_transactions/_transactions.html.haml +++ b/app/views/finance/financial_transactions/_transactions.html.haml @@ -37,6 +37,6 @@ %td= h t.financial_transaction_type.name %td= h t.note - FinancialTransactionClass.sorted.each do |c| - %td.currency{:style => "color:#{t.amount < 0 ? 'red' : 'black'}; width:5em"} + %td.numeric{style: 'width:5em'} - if t.financial_transaction_type.financial_transaction_class == c - = number_to_currency(t.amount) + = format_currency t.amount diff --git a/app/views/finance/index.html.haml b/app/views/finance/index.html.haml index 563c0411..e476ced4 100644 --- a/app/views/finance/index.html.haml +++ b/app/views/finance/index.html.haml @@ -36,7 +36,7 @@ %td= format_date(ft.created_on) %td= ft.ordergroup.name %td= ft.note - %td.numeric{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}"}= number_to_currency(ft.amount) + %td.numeric= format_currency ft.amount .span6 %h2 = t('.open_transactions') diff --git a/app/views/finance/ordergroups/_ordergroups.html.haml b/app/views/finance/ordergroups/_ordergroups.html.haml index 1ac47488..83a05ed2 100644 --- a/app/views/finance/ordergroups/_ordergroups.html.haml +++ b/app/views/finance/ordergroups/_ordergroups.html.haml @@ -17,8 +17,8 @@ %td= ordergroup.contact - FinancialTransactionClass.sorted.each do |c| - amount = ordergroup["sum_of_class_#{c.id}"] - %td.numeric{:style => "color:#{amount < 0 ? 'red' : 'black'}"} - = number_to_currency amount + %td.numeric + = format_currency amount %td = link_to t('.new_transaction'), new_finance_ordergroup_transaction_path(ordergroup), class: 'btn btn-mini' = link_to t('.account_statement'), finance_ordergroup_transactions_path(ordergroup), class: 'btn btn-mini' diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 3d67045c..8a80a39e 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -80,11 +80,10 @@ - if FinancialTransactionType.has_multiple_types %td= h(ft.financial_transaction_type.name) %td= h(ft.note) - - color = ft.amount < 0 ? 'red' : 'black' - FinancialTransactionClass.sorted.each do |fc| - %td{:style => "color:#{color}; width:5em", :class => "currency"} + %td.numeric{style: 'width:5em'} - if ft.financial_transaction_type.financial_transaction_class == fc - = number_to_currency(ft.amount) + = format_currency ft.amount -# placeholder deface to add content using erb[silent]:contains() - ''