Skip to content

add links to order_services in some accounting_posts cockpit columns (64083) #256

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions app/domain/order/cockpit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def overall_total_hours

def build_rows(period)
if sub_levels?
rows = accounting_posts.collect { |p| AccountingPostRow.new(p, period) }
rows = accounting_posts.collect { |p| AccountingPostRow.new(p, order, period) }
total = TotalRow.new(rows)
[total, *rows]
else
[AccountingPostRow.new(accounting_posts.first, period, order.work_item.path_shortnames)]
[AccountingPostRow.new(accounting_posts.first, order, period, order.work_item.path_shortnames)]
end
end

Expand Down
17 changes: 11 additions & 6 deletions app/domain/order/cockpit/accounting_post_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
class Order
class Cockpit
class AccountingPostRow < Row
include Rails.application.routes.url_helpers

attr_reader :cells, :accounting_post, :info

def initialize(accounting_post, period, label = nil)
def initialize(accounting_post, order, period, label = nil)
super(label || accounting_post.to_s)
@order = order
@period = period
@accounting_post = accounting_post
@cells = build_cells
Expand Down Expand Up @@ -75,15 +78,17 @@ def build_cells
end

def build_budget_cell
Cell.new(accounting_post.offered_hours, accounting_post.offered_total)
Cell.new(accounting_post.offered_hours, accounting_post.offered_total, nil)
end

def build_supplied_services_cell
build_cell_with_amount(supplied_services_hours)
build_cell_with_amount(supplied_services_hours,
order_order_services_path(@order.id, work_item_ids: accounting_post.work_item.id, start_date: @period.start_date, end_date: @period.end_date))
end

def build_not_billable_cell
Cell.new(not_billable_hours, calculate_amount(not_billable_hours))
link_path = order_order_services_path(@order.id, work_item_ids: accounting_post.work_item.id, billable: false, start_date: @period.start_date, end_date: @period.end_date)
Cell.new(not_billable_hours, calculate_amount(not_billable_hours), link_path)
end

def build_open_budget_cell
Expand All @@ -95,8 +100,8 @@ def build_planned_budget_cell
build_cell_with_amount(future_planned_hours)
end

def build_cell_with_amount(hours)
Cell.new(hours, calculate_amount(hours))
def build_cell_with_amount(hours, link = nil)
Cell.new(hours, calculate_amount(hours), link)
end

def calculate_amount(hours)
Expand Down
2 changes: 1 addition & 1 deletion app/domain/order/cockpit/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Order
class Cockpit
Cell = Struct.new(:hours, :amount) do
Cell = Struct.new(:hours, :amount, :link) do
def days
hours / must_hours_per_day if hours
end
Expand Down
3 changes: 2 additions & 1 deletion app/domain/order/cockpit/total_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def build_total_cells(rows)
master&.each_key do |key|
hash[key] =
Cell.new(sum_non_nil_values(cells, key, :hours, :to_d),
sum_non_nil_values(cells, key, :amount, :to_d))
sum_non_nil_values(cells, key, :amount, :to_d),
nil)
end
hash
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
.subtitle{title: row.name}= row.name
.data-item
%span.figure= f(row.offered_rate)
%span.unit= "#{currency}/Std."
%span.unit= "#{currency}/Std."
12 changes: 12 additions & 0 deletions app/views/accounting_posts/_cockpit_cell_contents.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.data-item
- if cell.hours
%span.figure= f(cell.hours.to_f)
%span.unit Std.
.data-item
- if cell.days
%span.figure= f(cell.days)
%span.unit Tage
.data-item
- if cell.amount
%span.figure.small= f(cell.amount.to_f)
%span.unit= currency
17 changes: 5 additions & 12 deletions app/views/accounting_posts/_cockpit_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,8 @@
%tr
- row.cells.each do |key, cell|
%td
.data-item
- if cell.hours
%span.figure= f(cell.hours.to_f)
%span.unit Std.
.data-item
- if cell.days
%span.figure= f(cell.days)
%span.unit Tage
.data-item
- if cell.amount
%span.figure.small= f(cell.amount.to_f)
%span.unit= currency
- if cell.link.present?
= link_to cell.link do
= render 'cockpit_cell_contents', cell: cell
- else
= render 'cockpit_cell_contents', cell: cell