Issue #16454 - Units and hours should be formatted as numbers in Excel export

In German Excel, number separator is ',', use I18n for translation

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@1048 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
t.felgentreff 15 years ago
parent 89c9aece9d
commit c0e84ff95a
  1. 20
      lib/xls_report/cost_reports_controller_patch.rb

@ -55,12 +55,12 @@ if require_dependency 'cost_reports_controller'
entry.issue ? entry.issue_id : "", entry.issue ? entry.issue_id : "",
entry.comments, entry.comments,
if entry.is_a?(CostEntry) if entry.is_a?(CostEntry)
"#{entry.units} #{entry.cost_type.unit_plural}" entry.units
elsif entry.is_a?(TimeEntry) elsif entry.is_a?(TimeEntry)
"#{entry.hours} h" entry.hours
end, end,
entry.is_a?(CostEntry) ? entry.cost_type.name : l(:caption_labor_costs), entry.is_a?(CostEntry) ? entry.cost_type.name : l(:caption_labor_costs),
entry.display_costs ? entry.real_costs : ""] entry.display_costs ? entry.real_costs.to_f : ""]
sb.add_row entry_fields sb.add_row entry_fields
end end
else else
@ -74,10 +74,10 @@ if require_dependency 'cost_reports_controller'
end, end,
"Sum"].compact "Sum"].compact
sb.add_format_option_to_column 1, :number_format => "0" sb.add_format_option_to_column 1, :number_format => "0"
sb.add_format_option_to_column 2, :number_format => "0#{t(:number)[:format][:separator]}00"
sb.add_format_option_to_column 3, :number_format => "0#{t(:number)[:format][:separator]}00"
if (@query.group_by["name"] == "cost_type_id") || (!display_costs) if (@query.group_by["name"] == "cost_type_id") || (!display_costs)
sb.add_format_option_to_column 3, :number_format => number_to_currency(0.00) sb.add_format_option_to_column 4, :number_format => "0#{t(:number)[:format][:separator]}00"
else
sb.add_format_option_to_column 2, :number_format => number_to_currency(0.00)
end end
@grouped_entries.each do |entry| @grouped_entries.each do |entry|
@ -97,13 +97,9 @@ if require_dependency 'cost_reports_controller'
entry["count"].to_i, entry["count"].to_i,
if (@query.group_by["name"] == "cost_type_id") || (!display_costs) if (@query.group_by["name"] == "cost_type_id") || (!display_costs)
cost_type = CostType.find_by_id(entry["cost_type_id"]) cost_type = CostType.find_by_id(entry["cost_type_id"])
if cost_type (entry["unit_sum"] || 0).to_f
pluralize(entry["unit_sum"], cost_type.unit, cost_type.unit_plural)
else
l_hours(entry["unit_sum"] || "0")
end
end, end,
entry["sum"]].compact entry["sum"].to_f].compact
end end
end end
sb.xls sb.xls

Loading…
Cancel
Save