Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show orders without hours on closed order reports #220

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/order_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class OrderReportsController < ApplicationController
major_risk_value]

before_action :authorize_class
before_action :show_without_hours

def index
set_period
Expand All @@ -35,6 +36,10 @@ def index

private

def show_without_hours
params[:without_hours] = true if params[:closed].presence
end

def set_filter_values
@departments = Department.list
@clients = WorkItem.joins(:client).list
Expand Down
13 changes: 11 additions & 2 deletions app/domain/order/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def limit_value

def filters_defined?
filters = params.except(:action, :controller, :format, :utf8, :page,
:clear, :closed)
:clear, :closed, :without_hours)
filters.present? && filters.values.any?(&:present?)
end

Expand Down Expand Up @@ -126,11 +126,20 @@ def invoices_to_hash(result)
def build_entry(order, accounting_posts, hours, invoices)
posts = accounting_posts[order.id]
post_hours = hours.slice(*posts.keys)
return unless post_hours.values.any? { |h| h.values.sum > 0.0001 }

return unless show_without_hours? || booked_hours?(post_hours)

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

def show_without_hours?
params[:without_hours].presence || false
end

def booked_hours?(post_hours)
post_hours.values.any? { |h| h.values.sum > 0.0001 }
end

def filter_by_parent(orders)
if params[:category_work_item_id].present?
orders.where('? = ANY (work_items.path_ids)', params[:category_work_item_id])
Expand Down