OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
linting and method extraction
ulferts9dab30fcc2b1
diff --git a/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rb b/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rbindex 0f8f3391997..e8238615859 100644--- a/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rb+++ b/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rb@@ -3,16 +3,8 @@ class OpenProject::XlsExport::XlsViews::CostEntryTable < OpenProject::XlsExport:spreadsheet = OpenProject::XlsExport::SpreadsheetBuilder.new(I18n.t(:label_money))default_query = serialize_query_without_hidden(@query)- available_cost_type_tabs(options[:cost_types]).each_with_index do |ary, idx|- @query = CostQuery.deserialize(default_query)- @cost_type = nil- @unit_id = ary.first- name = ary.last-- if @unit_id != 0- @query.filter :cost_type_id, operator: '=', value: @unit_id.to_s- @cost_type = CostType.find(unit_id) if unit_id.positive?- end+ available_cost_type_tabs(options[:cost_types]).each_with_index do |(unit_id, name), idx|+ setup_query_for_tab(default_query, unit_id)spreadsheet.worksheet(idx, name)build_spreadsheet(spreadsheet)@@ -20,6 +12,17 @@ class OpenProject::XlsExport::XlsViews::CostEntryTable < OpenProject::XlsExport:spreadsheetend+ def setup_query_for_tab(query, unit_id)+ @query = CostQuery.deserialize(query)+ @cost_type = nil+ @unit_id = unit_id++ if @unit_id != 0+ @query.filter :cost_type_id, operator: '=', value: @unit_id.to_s+ @cost_type = CostType.find(unit_id) if unit_id.positive?+ end+ end+def build_spreadsheet(spreadsheet)set_title(spreadsheet)@@ -40,21 +43,30 @@ class OpenProject::XlsExport::XlsViews::CostEntryTable < OpenProject::XlsExport:enddef format_columns(spreadsheet)- spreadsheet.add_format_option_to_column(headers.length - 3, number_format: "0.0")- spreadsheet.add_format_option_to_column(headers.length - 1, number_format: "#,##0.00 [$#{Setting.plugin_openproject_costs['costs_currency']}]")+ spreadsheet.add_format_option_to_column(headers.length - 3,+ number_format: number_format)+ spreadsheet.add_format_option_to_column(headers.length - 1,+ number_format: currency_format)enddef build_cost_rows(spreadsheet)query.each_direct_result do |result|- row = cost_entry_attributes.map { |field| show_field field, result.fields[field.to_s] }- current_cost_type_id = result.fields['cost_type_id'].to_i+ spreadsheet.add_row(cost_row(result))+ end+ end- row << show_result(result, current_cost_type_id) # units- row << cost_type_label(current_cost_type_id, @cost_type) # cost type- row << show_result(result, 0) # costs/currency+ def cost_row(result)+ current_cost_type_id = result.fields['cost_type_id'].to_i- spreadsheet.add_row(row)- end+ cost_entry_attributes+ .map { |field| show_field field, result.fields[field.to_s] }+ .concat(+ [+ show_result(result, current_cost_type_id), # units+ cost_type_label(current_cost_type_id, @cost_type), # cost type+ show_result(result, 0) # costs/currency+ ]+ )enddef build_footer(spreadsheet)@@ -76,4 +88,12 @@ class OpenProject::XlsExport::XlsViews::CostEntryTable < OpenProject::XlsExport:def cost_entry_attributes%i[spent_on user_id activity_id issue_id comments project_id]end++ def currency_format+ "#,##0.00 [$#{Setting.plugin_openproject_costs['costs_currency']}]"+ end++ def number_format+ "0.0"+ endend