From 4b18f20eba5d057ee17d97be16f62161fcddb3e6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Mar 2010 08:14:39 +0000 Subject: [PATCH 1/2] updated views and helpers to specify the currency unit when outputting currency values. A label_currency localisation variable has been added to config/locales/en.yml --- app/helpers/deliverables_helper.rb | 4 ++-- app/views/deliverables/_budget.html.erb | 16 ++++++++-------- .../_deliverable_details_row.html.erb | 10 +++++----- .../_deliverable_summary_row.html.erb | 8 ++++---- config/locales/en.yml | 5 +++-- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/helpers/deliverables_helper.rb b/app/helpers/deliverables_helper.rb index 4840f7f..ea563b2 100644 --- a/app/helpers/deliverables_helper.rb +++ b/app/helpers/deliverables_helper.rb @@ -93,8 +93,8 @@ module DeliverablesHelper end def number_or_percent(number_field, percent_field) - return number_to_currency(number_field, :precision => 0) unless number_field.blank? + return number_to_currency(number_field, :unit => l(:label_currency), :precision => 0) unless number_field.blank? return number_to_percentage(percent_field, :precision => 0) unless percent_field.blank? - return "$0" + return number_to_currency(0, :unit => l(:label_currency), :precision => 0) end end diff --git a/app/views/deliverables/_budget.html.erb b/app/views/deliverables/_budget.html.erb index 541b54e..b00c6fc 100644 --- a/app/views/deliverables/_budget.html.erb +++ b/app/views/deliverables/_budget.html.erb @@ -7,7 +7,7 @@ <%= l(:field_budget) %> - <%= h number_to_currency(budget.budget, :precision => 0) %> + <%= h number_to_currency(budget.budget, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -18,7 +18,7 @@ <%= l(:label_labor_budget) %> - <%= h number_to_currency(budget.labor_budget, :precision => 0) %> + <%= h number_to_currency(budget.labor_budget, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -29,7 +29,7 @@ <%= l(:label_labor_budget_spent) %> - <%= h number_to_currency(budget.spent, :precision => 0) %> + <%= h number_to_currency(budget.spent, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -40,7 +40,7 @@ <%= l(:label_labor_budget_remaining) %> - <%= h number_to_currency(budget.labor_budget_left, :precision => 0) %> + <%= h number_to_currency(budget.labor_budget_left, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -71,7 +71,7 @@ <%= l(:label_overruns) %> - <%= h number_to_currency(budget.overruns, :precision => 0) %> + <%= h number_to_currency(budget.overruns, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -82,7 +82,7 @@ <%= l(:label_missing_on) %> <%= link_to('Deliverables:', :action => 'issues', :id => @project.id, :deliverable_id => :none) %> - <%= h number_to_currency(budget.amount_missing_on_deliverables, :precision => 0) %> + <%= h number_to_currency(budget.amount_missing_on_deliverables, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -99,7 +99,7 @@ - <%= h number_to_currency(budget.amount_missing_on_issues, :precision => 0) %> + <%= h number_to_currency(budget.amount_missing_on_issues, :unit => l(:label_currency), :precision => 0) %> <% end %> @@ -127,7 +127,7 @@ <%= l(:label_potential_profit) %> - <%= h number_to_currency(budget.profit, :precision => 0) %> + <%= h number_to_currency(budget.profit, :unit => l(:label_currency), :precision => 0) %> <% end %> diff --git a/app/views/deliverables/_deliverable_details_row.html.erb b/app/views/deliverables/_deliverable_details_row.html.erb index 1322dbf..c9fc97c 100644 --- a/app/views/deliverables/_deliverable_details_row.html.erb +++ b/app/views/deliverables/_deliverable_details_row.html.erb @@ -23,16 +23,16 @@ <%= row_with_double_data l(:label_hours_estimated), number_with_precision(deliverable.total_hours, 0), '' %> <% end %> <% if deliverable.fixed? %> - <%= row_with_double_data l(:label_fixed_amount), '', number_to_currency(deliverable.fixed_cost, :precision => 0) %> + <%= row_with_double_data l(:label_fixed_amount), '', number_to_currency(deliverable.fixed_cost, :unit => l(:label_currency), :precision => 0) %> <% end %> <% if deliverable.hours_used > 0 %> - <%= row_with_double_data l(:label_hours_used), number_with_precision(deliverable.hours_used,0), number_to_currency(deliverable.spent_by_members, :precision => 0) %> + <%= row_with_double_data l(:label_hours_used), number_with_precision(deliverable.hours_used,0), number_to_currency(deliverable.spent_by_members, :unit => l(:label_currency), :precision => 0) %>   <% deliverable.members_spent.each do |person| %> - <%= row_with_double_data(h(person.user.name), person.hours.round, number_to_currency(person.spent, :precision => 0)) %> + <%= row_with_double_data(h(person.user.name), person.hours.round, number_to_currency(person.spent, :unit => l(:label_currency), :precision => 0)) %> <% end %> <% end %> <% end %> @@ -41,10 +41,10 @@ - <%= row_with_data(l(:field_budget), number_to_currency(deliverable.budget, :precision => 0)) -%> + <%= row_with_data(l(:field_budget), number_to_currency(deliverable.budget, :unit => l(:label_currency), :precision => 0)) -%> <% if allowed_management? %> <% base_price_label = deliverable.hourly? ? l(:label_labor) : l(:label_fixed_amount) %> - <%= row_with_data(base_price_label, number_to_currency(deliverable.labor_budget || 0.0, :precision => 0)) -%> + <%= row_with_data(base_price_label, number_to_currency(deliverable.labor_budget || 0.0, :unit => l(:label_currency), :precision => 0)) -%> <%= row_with_data(l(:label_overhead), number_or_percent(deliverable.overhead, deliverable.overhead_percent)) -%> <%= row_with_data(l(:label_materials), number_or_percent(deliverable.materials, deliverable.materials_percent)) -%> <%= row_with_data(l(:label_potential_profit), number_or_percent(deliverable.profit, deliverable.profit_percent)) -%> diff --git a/app/views/deliverables/_deliverable_summary_row.html.erb b/app/views/deliverables/_deliverable_summary_row.html.erb index b700b2c..853fb5a 100644 --- a/app/views/deliverables/_deliverable_summary_row.html.erb +++ b/app/views/deliverables/_deliverable_summary_row.html.erb @@ -6,10 +6,10 @@ <%= content_tag(:td, deliverable.id) %> <%= content_tag(:td, h(deliverable.score.to_i), :class => 'score') if allowed_management? %> <%= content_tag(:td, h(deliverable.subject), :class => 'subject') %> - <%= content_tag(:td, number_to_currency(deliverable.budget || 0.0, :precision => 0), :class => 'budget') if allowed_management? %> - <%= content_tag(:td, number_to_currency(deliverable.labor_budget || 0.0, :precision => 0), :class => 'budget') if allowed_management? %> - <%= content_tag(:td, number_to_currency(deliverable.spent, :precision => 0), :class => 'spent') if allowed_management? %> + <%= content_tag(:td, number_to_currency(deliverable.budget || 0.0, :unit => l(:label_currency), :precision => 0), :class => 'budget') if allowed_management? %> + <%= content_tag(:td, number_to_currency(deliverable.labor_budget || 0.0, :unit => l(:label_currency), :precision => 0), :class => 'budget') if allowed_management? %> + <%= content_tag(:td, number_to_currency(deliverable.spent, :unit => l(:label_currency), :precision => 0), :class => 'spent') if allowed_management? %> <%= content_tag(:td, format_date(deliverable.due), :class => 'due_date') %> <%= content_tag(:td, progress_bar(deliverable.progress, :width => '100%', :class => 'done_ratio')) %> <%= Redmine::Hook.call_hook(:plugin_budget_view_deliverable_summary_row, { :deliverable => deliverable }) %> - \ No newline at end of file + diff --git a/config/locales/en.yml b/config/locales/en.yml index 43052d6..b2f7d06 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,9 +15,10 @@ en: field_deliverable: Deliverable field_deliverable_subject: Deliverable field_due: Due Date - label_member_rate: Rate ($) + label_member_rate: Rate (£) + label_currency: £ message_updated_issues: Updated %d issues - message_budget_settings: Enter a dollar amount or percentage into each field to set your default amount. Use %% in the field for percentages. + message_budget_settings: Enter an amount in pounds, or a percentage into each field to set your default amount. Use %% in the field for percentages. label_non_billable_overhead: Non billable overhead label_materials: Materials label_profit: Profit From 2125241f381827c757a9b936e4eaf7c04faed57b Mon Sep 17 00:00:00 2001 From: Jon Pascoe Date: Wed, 3 Mar 2010 08:39:56 +0000 Subject: [PATCH 2/2] added new localisation variables to other configs to avoid breaking them --- config/locales/ca.yml | 1 + config/locales/es.yml | 1 + config/locales/hu.yml | 1 + config/locales/lt.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index e0f3257..f05c670 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -16,6 +16,7 @@ ca: field_deliverable_subject: Entregable field_due: Data finalització label_member_rate: Tarifa (EUR) + label_currency: € message_updated_issues: Actualitzats %d assumptes message_settings: Introduïu una quantitat en euros o un percentatge en cada camp per a establir un valor per defecte. Utilitzeu %% per indicar percentatges. label_non_billable_overhead: Imprevists no facturables diff --git a/config/locales/es.yml b/config/locales/es.yml index 11d6dfc..1df6ea4 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -16,6 +16,7 @@ es: field_deliverable_subject: Entregable field_due: Fecha entrega label_member_rate: Tarifa (EUR) + label_currency: € message_updated_issues: Actualizadas %d peticiones message_settings: Introduce cantidades en euros o porcentajes en cada campo para establecer los valores por defecto. Usa %% para indicar porcentajes. label_non_billable_overhead: Imprevistos no facturables diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 9cf501e..457a7df 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -12,4 +12,5 @@ hu: field_deliverable_subject: Teljesítés field_due: Esedékesség dátuma label_member_rate: Részesedés ($) + label_currency: $ message_updated_issues: Frissítve % feladat diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 5b527d2..8b4bb02 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -12,4 +12,5 @@ lt: field_deliverable_subject: Pateiktis field_due: Data iki label_member_rate: Užmokestis (LTL) + label_currency: $ message_updated_issues: Atnaujinta(i) %d darbų(ai)