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.



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

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

Instance Attribute Details

#monthObject (readonly)

Returns the value of attribute month.



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

def month
  @month
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



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

def year
  @year
end

Instance Method Details

#creditoObject



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

def credito
  summary_minutes(CREDITO_CODE)
end

#credito_acumObject



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

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

#data_uncachedObject



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

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

#debitoObject



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

def debito
  summary_minutes(DEBITO_CODE)
end

#debito_acumObject



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

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

#debito_acumuladoObject



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

def debito_acumulado; end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  os_data.summaries.empty?
end

#saldoObject



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

def saldo
  credito - debito
end

#saldo_acumObject



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

def saldo_acum
  credito_acum - debito_acum
end

#to_sObject



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

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