Class: Subledger::Domain::ReportRendering

Defined Under Namespace

Classes: Entity

Instance Attribute Summary collapse

Attributes included from Subledger::Domain::Roles::Storable

#client, #store

Attributes included from Subledger::Domain::Roles::Identifiable

#id

Attributes included from Subledger::Domain::Roles::DescribableReportRendering

#description, #reference

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Subledger::Domain::Roles::Restable

#patch_hash, #post_hash, #serializable_hash, #to_json

Methods included from Subledger::Domain::Roles::Collectable

included

Methods included from Subledger::Domain::Roles::Readable

included, #read

Methods included from Subledger::Domain::Roles::Creatable

#create, included

Methods included from Subledger::Domain::Roles::Attributable

#attributes

Methods included from Subledger::Domain

#==, #collection_name, #entity_name, included, #to_s

Constructor Details

#initialize(args) ⇒ ReportRendering

Returns a new instance of ReportRendering.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/subledger/domain/report_rendering.rb', line 50

def initialize args
  describable_report_rendering args
  identifiable args
  storable args

  @book              = args[:book]
  @report            = args[:report]
  @effective_at      = round args[:effective_at]
  @rendered_at       = utc_or_now args[:rendered_at]

  @balanced_accounts = args[:balanced_accounts] || 0
  @total_accounts    = args[:total_accounts]    || 0

  specialized_initialization args
end

Instance Attribute Details

#balanced_accountsObject (readonly)

Returns the value of attribute balanced_accounts.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def balanced_accounts
  @balanced_accounts
end

#bookObject (readonly)

Returns the value of attribute book.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def book
  @book
end

#effective_atObject (readonly)

Returns the value of attribute effective_at.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def effective_at
  @effective_at
end

#rendered_atObject (readonly)

Returns the value of attribute rendered_at.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def rendered_at
  @rendered_at
end

#reportObject (readonly)

Returns the value of attribute report.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def report
  @report
end

#total_accountsObject (readonly)

Returns the value of attribute total_accounts.



22
23
24
# File 'lib/subledger/domain/report_rendering.rb', line 22

def total_accounts
  @total_accounts
end

Class Method Details

.active_klassObject

TODO create uses active_klass, should use creation_klass



42
43
44
# File 'lib/subledger/domain/report_rendering.rb', line 42

def self.active_klass
  building_klass
end

.building_klassObject



37
38
39
# File 'lib/subledger/domain/report_rendering.rb', line 37

def self.building_klass
  BuildingReportRendering
end

.completed_klassObject



46
47
48
# File 'lib/subledger/domain/report_rendering.rb', line 46

def self.completed_klass
  CompletedReportRendering
end

.post_keysObject



25
26
27
# File 'lib/subledger/domain/report_rendering.rb', line 25

def self.post_keys
  [ :description, :reference, :report, :effective_at ]
end

.root_klassObject



29
30
31
# File 'lib/subledger/domain/report_rendering.rb', line 29

def self.root_klass
  ReportRendering
end

.sub_klassesObject



33
34
35
# File 'lib/subledger/domain/report_rendering.rb', line 33

def self.sub_klasses
  [ building_klass, completed_klass ]
end

Instance Method Details

#progressObject



66
67
68
69
70
71
72
# File 'lib/subledger/domain/report_rendering.rb', line 66

def progress
  if total_accounts.zero?
    0
  else
    ( ( balanced_accounts.to_f / total_accounts ) * 99 ).to_i
  end
end