Class: Shushu::UnitGroupPresenter

Inherits:
BasePresenter show all
Defined in:
lib/presenters/unit_group_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasePresenter

#add_commas, #date_range, #money, #pennies_to_dollar, #trunc_hours

Constructor Details

#initialize(unit_group) ⇒ UnitGroupPresenter

Returns a new instance of UnitGroupPresenter.



6
7
8
# File 'lib/presenters/unit_group_presenter.rb', line 6

def initialize(unit_group)
  @unit_group = unit_group
end

Instance Attribute Details

#unit_groupObject (readonly)

Returns the value of attribute unit_group.



4
5
6
# File 'lib/presenters/unit_group_presenter.rb', line 4

def unit_group
  @unit_group
end

Instance Method Details

#compacted_reportsObject



24
25
26
27
28
# File 'lib/presenters/unit_group_presenter.rb', line 24

def compacted_reports
  #TODO remove chart stub
  #BillableUnitReporter.compacted(@unit_group.units)
  []
end

#daily_report_urlObject



18
19
20
21
22
# File 'lib/presenters/unit_group_presenter.rb', line 18

def daily_report_url
  #TODO remove chart stub
  #payments_uri("/billable_units/daily")
  "/billable_units/daily"
end

#descriptionObject



46
47
48
# File 'lib/presenters/unit_group_presenter.rb', line 46

def description
  @unit_group.description
end

#idObject



10
11
12
# File 'lib/presenters/unit_group_presenter.rb', line 10

def id
  [:hid, :name].map {|m| unit_group.send(m)}.join("_").gsub("-", "_")
end

#nameObject



42
43
44
# File 'lib/presenters/unit_group_presenter.rb', line 42

def name
  @unit_group.name
end

#product_groupObject



54
55
56
# File 'lib/presenters/unit_group_presenter.rb', line 54

def product_group
  @unit_group.product_group
end

#product_nameObject



50
51
52
# File 'lib/presenters/unit_group_presenter.rb', line 50

def product_name
  @unit_group.product_name
end

#qtyObject



34
35
36
# File 'lib/presenters/unit_group_presenter.rb', line 34

def qty
  trunc_hours(@unit_group.qty)
end

#rateObject



38
39
40
# File 'lib/presenters/unit_group_presenter.rb', line 38

def rate
  @unit_group.rate
end

#totalObject



30
31
32
# File 'lib/presenters/unit_group_presenter.rb', line 30

def total
  money(@unit_group.total)
end

#unit_of_measureObject



58
59
60
# File 'lib/presenters/unit_group_presenter.rb', line 58

def unit_of_measure
  @unit_group.rate_period
end

#unit_presentersObject



14
15
16
# File 'lib/presenters/unit_group_presenter.rb', line 14

def unit_presenters
  @unit_presenters ||= @unit_group.units.map {|u| UnitPresenter.new(u)}
end