Defect #8368
Bad decimal separator in time entry CSV
| Status: | Closed | Start date: | 2011-05-13 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Toshi MARUYAMA | % Done: | 100% |
|
| Category: | Time tracking | |||
| Target version: | 1.3.0 | |||
| Affected version: | Resolution: | Fixed |
Description
In file app/helpers/timelog_helper.rb
I've patched two methods do not correctly display the decimal format, because they aren't reading general_csv_decimal_separator. Here are the new methods I've patched:
1def report_to_csv_with_td_csv(criterias, periods, hours) 2 decimal_separator = l(:general_csv_decimal_separator) 3 4 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| 5 # Column headers 6 headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) } 7 headers += periods 8 headers << l(:label_total) 9 csv << headers.collect {|c| to_utf8(c) } 10 # Content 11 report_criteria_to_csv(csv, criterias, periods, hours) 12 # Total row 13 row = [ l(:label_total) ] + [''] * (criterias.size - 1) 14 total = 0 15 periods.each do |period| 16 sum = sum_hours(select_hours(hours, @columns, period.to_s)) 17 total += sum 18 row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '') 19 end 20 row << ("%.2f" %total).gsub('.',decimal_separator) 21 csv << row 22 end 23 export 24end 25 26def report_criteria_to_csv_with_td_csv(csv, criterias, periods, hours, level=0) 27 decimal_separator = l(:general_csv_decimal_separator) 28 29 hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value| 30 hours_for_value = select_hours(hours, criterias[level], value) 31 next if hours_for_value.empty? 32 row = [''] * level 33 row << to_utf8(format_criteria_value(criterias[level], value)) 34 row += [''] * (criterias.length - level - 1) 35 total = 0 36 periods.each do |period| 37 sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s)) 38 total += sum 39 row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '') 40 end 41 row << ("%.2f" %total).gsub('.',decimal_separator) 42 csv << row 43 44 if criterias.length > level + 1 45 report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1) 46 end 47 end 48end
Related issues
Associated revisions
add tests to export issues csv in Traditional Chinese and French for csv separator (#8368)
add tests to export time log csv in Traditional Chinese and French for csv separator (#8368)
add csv separator check to the test to export time entry csv in Traditional Chinese (#8368)
fix csv decimal separator of time entry csv (#8368)
Contributed by Francisco José Martínez.
add tests to export time entry csv in French for csv separator (#8368)
History
#1 Updated by Etienne Massip about 1 year ago
- Category set to Time tracking
#2 Updated by Etienne Massip about 1 year ago
- Target version set to Candidate for next minor release
Seems you found inspiration in IssueHelper#issues_to_csv, looks fine to me.
Could you post a .patch/.diff file instead of the whole changed methods, please ?
#3 Updated by Etienne Massip about 1 year ago
- Target version changed from Candidate for next minor release to Candidate for next major release
#4 Updated by Francisco José Martínez about 1 year ago
- File timelog_helper.patch added
Sorry, this is my first patch.
Affirmative, the inspiration came from IssueHelper#issues_to_csv
#5 Updated by Toshi MARUYAMA 12 months ago
- Assignee set to Toshi MARUYAMA
- Target version changed from Candidate for next major release to 1.3.0
#6 Updated by Toshi MARUYAMA 6 months ago
- Tracker changed from Patch to Defect
- Target version changed from 1.3.0 to 1.2.3
#7 Updated by Toshi MARUYAMA 6 months ago
- Subject changed from Fixing bad format in CSV exports to Bad decimal separator in time entry CSV
#8 Updated by Toshi MARUYAMA 6 months ago
- Status changed from New to Confirmed
#9 Updated by Toshi MARUYAMA 6 months ago
- Target version changed from 1.2.3 to 1.3.0
#10 Updated by Toshi MARUYAMA 6 months ago
- % Done changed from 0 to 100
#11 Updated by Toshi MARUYAMA 6 months ago
- Status changed from Confirmed to Closed
- Resolution set to Fixed
Committed in r7951.
