Module: Treasurer::LocalCustomisations

Defined in:
lib/treasurer/local_customisations.rb

Overview

class CodeRunner::Budget

Constant Summary collapse

REGULAR_TRANSFERS =
{
  [:FirstBank, :SecondBank] =>{
    topup: {size: 200, period: [1, :month], monthday: 1, end: Date.parse("01/10/2014")},
  },
  [:FirstBank, :Rent] =>{
    house: {size: 600, period: [1, :month], monthday: 20, end: Date.parse("01/07/2013")},
  },
  [:Income, :FirstBank] =>{
    pay: {size: 1200, period: [1, :month], monthday: 1, end: Date.parse("01/07/2014")},
  },
 
}
FUTURE_TRANSFERS =
{
  [:Income, :SecondBank] =>{
    bonus: {size: 100, date: Date.parse("26/09/2010")},
  },
  [:FirstBank, :PersonalLoans] =>{
    payfriend: {size: 640, date: Date.parse("25/09/2010")},
    borrowfromfriend: {size: -840, date: Date.parse("28/09/2010")},
  },
 
}
ACCOUNT_INFO =
{
  Monthly: {linked_account: :FirstBank, period: [1, :month], monthday: 1, start: nil, end: nil, discretionary: false},
  MonthlySecondBank: {linked_account: :SecondBank, period: [1, :month], monthday: 1, start: nil, end: nil, discretionary: false},
  Weekly: {linked_account: :FirstBank, period: [7, :day], monthday: nil, start: nil, end: nil, discretionary: true},
  WeeklySecondBank: {linked_account: :SecondBank, period: [7, :day], monthday: nil, start: nil, end: nil, discretionary: true},
  MyHoliday: {linked_account: :SecondBank, period: [1, :day], monthday: nil, start: Date.parse("02/12/2013"), end: Date.parse("2/01/2014"), discretionary: false},
  PersonalLoans: {type: :Liability},
  FirstBank: {type: :Asset},
  SecondBank: {type: :Asset},
  Pay: {linked_account: :FirstBank, type: :Income},
}

Instance Method Summary collapse

Instance Method Details

#account_type(account) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/treasurer/local_customisations.rb', line 51

def ()
  case 
  when :Food, :Phone, :Rent, :Cash, :Entertainment, :Books, :Insurance
    :Expense
  when :FirstBank, :SecondBank
    :Asset
  when :PersonalLoans
    :Liability
  else
    :Expense
  end
end

#external_accountObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/treasurer/local_customisations.rb', line 97

def 
  case description
  when /Vodafone/i
    :Monthly
  when /norries/i
    :PersonalLoans
  when /my employer/i
    :Pay
  else
    case 
    when :Food, :Entertainment
      :Weekly
    when :Insurance, :Phone, :Rent
      :Monthly
    when :Books, :Cash
      :WeeklySecondBank
    else
      :Unknown
    end
  end
end

#in_date(item) ⇒ Object



47
48
49
# File 'lib/treasurer/local_customisations.rb', line 47

def in_date(item)
  (!item[:start] or date >= item[:start]) and (!item[:end] || date <= item[:end])
end

#red_line(account, date) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/treasurer/local_customisations.rb', line 64

def red_line(, date)
  case 
  when :FirstBank
    -350
  when :SecondBank
    0
  else
    0
  end
end

#sub_accountObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/treasurer/local_customisations.rb', line 76

def 
  case description
  when /co-op|sainsbury/i 
    :Food
  when /insurance/i
    :Insurance
  when /Vodafone/i
    :Phone
  when /Adams/i
    :Rent
  when /Carfax|Lnk/i
    :Cash
  when /andalus/i, /angels/i, /maggie arms/i, /barley mow/i
    :Entertainment
  when /blackwell/i
    :Books
  else
    :Unknown
  end
end