Skip to content

Commit 2e10d9a

Browse files
committed
Show orders without hours on closed order reports
1 parent 2bda281 commit 2e10d9a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

app/controllers/order_reports_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class OrderReportsController < ApplicationController
1515
major_risk_value]
1616

1717
before_action :authorize_class
18+
before_action :show_without_hours
1819

1920
def index
2021
set_period
@@ -35,6 +36,10 @@ def index
3536

3637
private
3738

39+
def show_without_hours
40+
params[:without_hours] = true if params[:closed].presence
41+
end
42+
3843
def set_filter_values
3944
@departments = Department.list
4045
@clients = WorkItem.joins(:client).list

app/domain/order/report.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def limit_value
4545

4646
def filters_defined?
4747
filters = params.except(:action, :controller, :format, :utf8, :page,
48-
:clear, :closed)
48+
:clear, :closed, :without_hours)
4949
filters.present? && filters.values.any?(&:present?)
5050
end
5151

@@ -126,11 +126,20 @@ def invoices_to_hash(result)
126126
def build_entry(order, accounting_posts, hours, invoices)
127127
posts = accounting_posts[order.id]
128128
post_hours = hours.slice(*posts.keys)
129-
return unless post_hours.values.any? { |h| h.values.sum > 0.0001 }
129+
130+
return unless show_without_hours? || booked_hours?(post_hours)
130131

131132
Order::Report::Entry.new(order, posts, post_hours, invoices[order.id])
132133
end
133134

135+
def show_without_hours?
136+
params[:without_hours].presence || false
137+
end
138+
139+
def booked_hours?(post_hours)
140+
post_hours.values.any? { |h| h.values.sum > 0.0001 }
141+
end
142+
134143
def filter_by_parent(orders)
135144
if params[:category_work_item_id].present?
136145
orders.where('? = ANY (work_items.path_ids)', params[:category_work_item_id])

0 commit comments

Comments
 (0)