-
-
Notifications
You must be signed in to change notification settings - Fork 573
Expand file tree
/
Copy pathdashboard_helper.rb
More file actions
28 lines (22 loc) · 809 Bytes
/
dashboard_helper.rb
File metadata and controls
28 lines (22 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Encapsulates methods used on the Dashboard that need some business logic
module DashboardHelper
def total_on_hand(total = nil)
number_with_delimiter(total || "-1")
end
def total_distributed(range = selected_range)
number_with_delimiter total_distributed_unformatted(range)
end
def future_distributed
number_with_delimiter future_distributed_unformatted
end
def recently_added_user_display_text(user)
user.name.blank? ? user.email : user.display_name
end
private
def total_distributed_unformatted(range = selected_range)
LineItem.where(itemizable: current_organization.distributions.during(range)).sum(:quantity)
end
def future_distributed_unformatted
LineItem.active.where(itemizable: current_organization.distributions.future).sum(:quantity)
end
end