Class: Avmtrf1::Forponto::User::Month

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/forponto/user/month.rb

Constant Summary collapse

DEBITO_CODE =
66
CREDITO_CODE =
72

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, year, month) ⇒ Month

Returns a new instance of Month.



21
22
23
24
25
# File 'lib/avmtrf1/forponto/user/month.rb', line 21

def initialize(user, year, month)
  @user = user
  @year = year
  @month = month
end

Instance Attribute Details

#monthObject (readonly)

Returns the value of attribute month.



19
20
21
# File 'lib/avmtrf1/forponto/user/month.rb', line 19

def month
  @month
end

#userObject (readonly)

Returns the value of attribute user.



19
20
21
# File 'lib/avmtrf1/forponto/user/month.rb', line 19

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



19
20
21
# File 'lib/avmtrf1/forponto/user/month.rb', line 19

def year
  @year
end

Instance Method Details

#creditoObject



67
68
69
# File 'lib/avmtrf1/forponto/user/month.rb', line 67

def credito
  summary_minutes(CREDITO_CODE)
end

#credito_acumObject



55
56
57
# File 'lib/avmtrf1/forponto/user/month.rb', line 55

def credito_acum
  credito + (parent_month ? parent_month.credito_acum : 0)
end

#data_uncachedObject



27
28
29
30
31
32
33
34
35
# File 'lib/avmtrf1/forponto/user/month.rb', line 27

def data_uncached
  if recache?
    r = fresh_data
    data_cache.write(r.to_yaml)
    r
  else
    cached_data
  end
end

#debitoObject



47
48
49
# File 'lib/avmtrf1/forponto/user/month.rb', line 47

def debito
  summary_minutes(DEBITO_CODE)
end

#debito_acumObject



51
52
53
# File 'lib/avmtrf1/forponto/user/month.rb', line 51

def debito_acum
  debito + (parent_month ? parent_month.debito_acum : 0)
end

#debito_acumuladoObject



45
# File 'lib/avmtrf1/forponto/user/month.rb', line 45

def debito_acumulado; end

#empty?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/avmtrf1/forponto/user/month.rb', line 41

def empty?
  os_data.summaries.empty?
end

#saldoObject



59
60
61
# File 'lib/avmtrf1/forponto/user/month.rb', line 59

def saldo
  credito - debito
end

#saldo_acumObject



63
64
65
# File 'lib/avmtrf1/forponto/user/month.rb', line 63

def saldo_acum
  credito_acum - debito_acum
end

#to_sObject



37
38
39
# File 'lib/avmtrf1/forponto/user/month.rb', line 37

def to_s
  month.to_s.rjust(2, '0') + '/' + year.to_s
end