Skip to content

Commit

Permalink
Show orders without hours on closed order reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Oct 29, 2024
1 parent 2bda281 commit bfa1339
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit bfa1339

Please sign in to comment.