Skip to content

Commit

Permalink
Merge pull request #299 from sparc-request/jl-exclude-first-drafts-fr…
Browse files Browse the repository at this point in the history
…om-consolidated

Excluding requests with 'draft' or 'first_draft' status from consolid…
  • Loading branch information
jleonardw9 committed Mar 7, 2016
2 parents dcc4942 + cc65ea2 commit 3f85a65
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions app/views/portal/protocols/show.xlsx.axlsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ wb.add_worksheet(name: "Consolidated Report") do |sheet|

sheet.add_row(r_t_row, :style => centered)

grouped_line_items_visits = arm.line_items_visits.group_by{|liv| liv.line_item.sub_service_request.org_tree_display}
filtered_line_items_visits = arm.line_items_visits.reject{|liv| ['first_draft', 'draft'].include?(liv.line_item.service_request.status)}

grouped_line_items_visits = filtered_line_items_visits.group_by{|liv| liv.line_item.sub_service_request.org_tree_display}


grouped_line_items_visits.each do |org, line_item_visits|
Expand Down Expand Up @@ -250,15 +252,19 @@ wb.add_worksheet(name: "Consolidated Report") do |sheet|
total = 0

@protocol.service_requests.each do |service_request|
total += service_request.direct_cost_total(service_request.line_items)
unless ['first_draft', 'draft'].include?(service_request.status)
total += service_request.direct_cost_total(service_request.line_items)
end
end

direct_cost_total_row += ["Total Direct Cost", "", "", number_to_currency(total / 100)]
else
total = 0

@protocol.service_requests.each do |service_request|
total += service_request.direct_cost_total(service_request.line_items)
unless ['first_draft', 'draft'].include?(service_request.status)
total += service_request.direct_cost_total(service_request.line_items)
end
end

direct_cost_total_row += ["Total Direct Cost", number_to_currency(total / 100)]
Expand All @@ -281,7 +287,9 @@ wb.add_worksheet(name: "Consolidated Report") do |sheet|
total = 0

@protocol.service_requests.each do |service_request|
total += service_request.indirect_cost_total(service_request.line_items)
unless ['first_draft', 'draft'].include?(service_request.status)
total += service_request.indirect_cost_total(service_request.line_items)
end
end

indirect_cost_total_row += ["Total Direct Cost", "", "", number_to_currency(total / 100)]
Expand Down Expand Up @@ -312,15 +320,19 @@ wb.add_worksheet(name: "Consolidated Report") do |sheet|
total = 0

@protocol.service_requests.each do |service_request|
total += service_request.grand_total(service_request.line_items)
unless ['first_draft', 'draft'].include?(service_request.status)
total += service_request.grand_total(service_request.line_items)
end
end

grand_total_row += ["Grand Total", "", "", number_to_currency(total / 100)]
else
total = 0

@protocol.service_requests.each do |service_request|
total += service_request.grand_total(service_request.line_items)
unless ['first_draft', 'draft'].include?(service_request.status)
total += service_request.grand_total(service_request.line_items)
end
end

grand_total_row += ["Grand Total", number_to_currency(total / 100)]
Expand Down

0 comments on commit 3f85a65

Please sign in to comment.