プロジェクト

全般

プロフィール

Vote #69909

完了

Bad decimal separator in time entry CSV

Admin Redmine さんが約3年前に追加. 約3年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Time tracking_13
対象バージョン:
開始日:
2011/05/13
期日:
進捗率:

100%

予定工数:
category_id:
13
version_id:
36
issue_org_id:
8368
author_id:
28092
assigned_to_id:
11192
comments:
11
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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:


def report_to_csv_with_td_csv(criterias, periods, hours)
  decimal_separator = l(:general_csv_decimal_separator)

  export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
    # Column headers
    headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) }
    headers += periods
    headers << l(:label_total)
    csv << headers.collect {|c| to_utf8(c) }
    # Content
    report_criteria_to_csv(csv, criterias, periods, hours)
    # Total row
    row = [ l(:label_total) ] + [''] * (criterias.size - 1)
    total = 0
    periods.each do |period|
      sum = sum_hours(select_hours(hours, @columns, period.to_s)) 
      total += sum
      row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
    end
    row << ("%.2f" %total).gsub('.',decimal_separator)
    csv << row
  end
  export      
end

def report_criteria_to_csv_with_td_csv(csv, criterias, periods, hours, level=0)
  decimal_separator = l(:general_csv_decimal_separator)

  hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
    hours_for_value = select_hours(hours, criterias[level], value)
    next if hours_for_value.empty?
    row = [''] * level
    row << to_utf8(format_criteria_value(criterias[level], value))
    row += [''] * (criterias.length - level - 1)
    total = 0
    periods.each do |period|
      sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s))
      total += sum
      row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
    end
    row << ("%.2f" %total).gsub('.',decimal_separator)
    csv << row

    if criterias.length > level + 1
      report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
    end
  end     
end

journals

--------------------------------------------------------------------------------
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 ?

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Sorry, this is my first patch.
Affirmative, the inspiration came from IssueHelper#issues_to_csv
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed in r7951.
--------------------------------------------------------------------------------


related_issues

relates,Closed,7096,CSV Issues Export + Ruby 1.9 + Thin + non-ascii characters causes "invalid byte sequence in US-ASCII"
duplicates,Closed,9907,CSV Seperator is not used when exporting Time Report as CSV

Admin Redmine さんが約3年前に更新

  • カテゴリTime tracking_13 にセット
  • 対象バージョン1.3.0_36 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0