Skip to content

Commit 85ac54e

Browse files
anna-devKagemaru
authored andcommitted
Add links to accounting post order service total columns (64388)
1 parent b5a52f8 commit 85ac54e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

app/domain/order/cockpit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def overall_total_hours
7474
def build_rows(period)
7575
if sub_levels?
7676
rows = accounting_posts.collect { |p| AccountingPostRow.new(p, order, period) }
77-
total = TotalRow.new(rows)
77+
total = TotalRow.new(order, period, rows)
7878
[total, *rows]
7979
else
8080
[AccountingPostRow.new(accounting_posts.first, order, period, order.work_item.path_shortnames)]

app/domain/order/cockpit/total_row.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
class Order
99
class Cockpit
1010
class TotalRow < Row
11-
attr_reader :info
11+
include Rails.application.routes.url_helpers
12+
attr_reader :info, :order, :period
1213

13-
def initialize(rows)
14+
def initialize(order, period, rows)
1415
super('Total')
16+
@order = order
17+
@period = period
1518
@cells = build_total_cells(rows)
1619
@info = build_info(rows)
1720
end
@@ -25,7 +28,8 @@ def build_total_cells(rows)
2528
master&.each_key do |key|
2629
hash[key] =
2730
Cell.new(sum_non_nil_values(cells, key, :hours, :to_d),
28-
sum_non_nil_values(cells, key, :amount, :to_d))
31+
sum_non_nil_values(cells, key, :amount, :to_d),
32+
link_path)
2933
end
3034
hash
3135
end
@@ -44,6 +48,14 @@ def sum_non_nil_values(cells, key, field, converter)
4448

4549
values.sum(&converter)
4650
end
51+
52+
def link_path
53+
@link_path ||= order_order_services_path(
54+
@order.id,
55+
start_date: @period.start_date,
56+
end_date: @period.end_date
57+
)
58+
end
4759
end
4860
end
4961
end

0 commit comments

Comments
 (0)