real_estate_finance 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c1e12322fd45de4d8458a8b425d3b9d28016531
4
+ data.tar.gz: 881eb0754527da6a6bbee8496753fbdd9c185f0d
5
+ SHA512:
6
+ metadata.gz: 603d16e3dbec68c32defcb05b5f6ef6228934fbd64971d17eeedc4b2b90b2a261017a9713d64156c17fcc25c6ba69b5422f909badb290eaba6e7945192f78c5b
7
+ data.tar.gz: 0a47def3a58f615d7aa8f0fa45ab2ad35c454287fcff104cdf5f8cfc147b80e4ef4de6db982989b0e99adef4fdb040af824395a53b6117b6de3986335ed79be3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in real_estate_finance.gemspec
4
+ gemspec
@@ -0,0 +1,109 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard 'livereload' do
19
+ extensions = {
20
+ css: :css,
21
+ scss: :css,
22
+ sass: :css,
23
+ js: :js,
24
+ coffee: :js,
25
+ html: :html,
26
+ png: :png,
27
+ gif: :gif,
28
+ jpg: :jpg,
29
+ jpeg: :jpeg,
30
+ # less: :less, # uncomment if you want LESS stylesheets done in browser
31
+ }
32
+
33
+ rails_view_exts = %w(erb haml slim)
34
+
35
+ # file types LiveReload may optimize refresh for
36
+ compiled_exts = extensions.values.uniq
37
+ watch(%r{public/.+\.(#{compiled_exts * '|'})})
38
+
39
+ extensions.each do |ext, type|
40
+ watch(%r{
41
+ (?:app|vendor)
42
+ (?:/assets/\w+/(?<path>[^.]+) # path+base without extension
43
+ (?<ext>\.#{ext})) # matching extension (must be first encountered)
44
+ (?:\.\w+|$) # other extensions
45
+ }x) do |m|
46
+ path = m[1]
47
+ "/assets/#{path}.#{type}"
48
+ end
49
+ end
50
+
51
+ # file needing a full reload of the page anyway
52
+ watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
53
+ watch(%r{app/helpers/.+\.rb})
54
+ watch(%r{config/locales/.+\.yml})
55
+ end
56
+
57
+ # Note: The cmd option is now required due to the increasing number of ways
58
+ # rspec may be run, below are examples of the most common uses.
59
+ # * bundler: 'bundle exec rspec'
60
+ # * bundler binstubs: 'bin/rspec'
61
+ # * spring: 'bin/rspec' (This will use spring if running and you have
62
+ # installed the spring binstubs per the docs)
63
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
64
+ # * 'just' rspec: 'rspec'
65
+
66
+ guard :rspec, cmd: "bundle exec rspec" do
67
+ require "guard/rspec/dsl"
68
+ dsl = Guard::RSpec::Dsl.new(self)
69
+
70
+ # Feel free to open issues for suggestions and improvements
71
+
72
+ # RSpec files
73
+ rspec = dsl.rspec
74
+ watch(rspec.spec_helper) { rspec.spec_dir }
75
+ watch(rspec.spec_support) { rspec.spec_dir }
76
+ watch(rspec.spec_files)
77
+
78
+ # Ruby files
79
+ ruby = dsl.ruby
80
+ dsl.watch_spec_files_for(ruby.lib_files)
81
+
82
+ # Rails files
83
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
84
+ dsl.watch_spec_files_for(rails.app_files)
85
+ dsl.watch_spec_files_for(rails.views)
86
+
87
+ watch(rails.controllers) do |m|
88
+ [
89
+ rspec.spec.call("routing/#{m[1]}_routing"),
90
+ rspec.spec.call("controllers/#{m[1]}_controller"),
91
+ rspec.spec.call("acceptance/#{m[1]}")
92
+ ]
93
+ end
94
+
95
+ # Rails config changes
96
+ watch(rails.spec_helper) { rspec.spec_dir }
97
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
98
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
99
+
100
+ # Capybara features specs
101
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
102
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
103
+
104
+ # Turnip features and steps
105
+ watch(%r{^spec/acceptance/(.+)\.feature$})
106
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
107
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
108
+ end
109
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Alexander Aleksanyan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,242 @@
1
+ # RealEstateFinance
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'real_estate_finance'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install real_estate_finance
18
+
19
+ ## Usage
20
+
21
+ ## Functions Available
22
+
23
+ - All inputs are meant to be in their specifc order listed below and all inputs are meant to be Numbers, not Strings or Floats!
24
+
25
+ - Most outputs are Floats...
26
+
27
+ <hr/>
28
+
29
+ - gross_potential_income
30
+ <code>
31
+ RealEstateFinance::GrossPotentialIncome.new(monthly_income).gross_potential_income
32
+ </code>
33
+
34
+ - net_operating_income
35
+ <code>
36
+ RealEstateFinance::NetOperatingIncome.new(
37
+ monthly_income,
38
+ vacancies,
39
+ non_payments,
40
+ taxes,
41
+ mortgage_interest,
42
+ marketing,
43
+ advertising,
44
+ management,
45
+ legal,
46
+ accounting,
47
+ utilities,
48
+ repairs,
49
+ maintenance,
50
+ acquisition,
51
+ sale_costs
52
+ ).net_operating_income
53
+ </code>
54
+
55
+
56
+ - gross_rental_multiplier
57
+ <code>
58
+ RealEstateFinance::GrossRentalMultiplier.new(
59
+ marketValue,
60
+ monthly_income
61
+ ).gross_rental_multiplier
62
+ </code>
63
+
64
+ - estimated_property_value_from_grm
65
+ <code>
66
+ RealEstateFinance::EstimatedPropertyValueFromGRM.new(
67
+ market_value,
68
+ monthly_income
69
+ ).estimated_property_value_from_grm
70
+ </code>
71
+
72
+ - gross_operating_income
73
+ <code>
74
+ RealEstateFinance::GrossOperatingIncome.new(
75
+ monthly_income,
76
+ estimated_loss_percentage
77
+ ).gross_operating_income
78
+ </code>
79
+
80
+ - capitalization_rate
81
+ <code>
82
+ RealEstateFinance::CapitalizationRate.new(
83
+ monthly_income,
84
+ vacancies,
85
+ non_payments,
86
+ taxes,
87
+ marketing,
88
+ advertising,
89
+ management,
90
+ legal,
91
+ accouting,
92
+ utilities,
93
+ repairs,
94
+ maintenance,
95
+ acquisition,
96
+ sale_costs,
97
+ sale_earned
98
+ ).capitalization_rate
99
+ </code>
100
+
101
+ - estimated_property_value_from_cap_rate
102
+ <code>
103
+ RealEstateFinance::EstimatedPropertyValueFromCapRate.new(
104
+ monthly_income,
105
+ vacancies,
106
+ non_payments,
107
+ taxes,
108
+ mortgage_interest,
109
+ marketing,
110
+ advertising,
111
+ management,
112
+ legal,
113
+ accounting,
114
+ utilities,
115
+ repairs,
116
+ maintenance,
117
+ acquisition,
118
+ sale_costs,
119
+ sale_earned
120
+ ).estimated_property_value_from_cap_rate
121
+ </code>
122
+
123
+
124
+ - cash_flow_before_taxes
125
+ <code>
126
+ RealEstateFinance::CashFlowBeforeTaxes.new(
127
+ monthly_income,
128
+ vacancies,
129
+ non_payments,
130
+ taxes,
131
+ mortgage_interest,
132
+ marketing,
133
+ advertising,
134
+ management,
135
+ legal,
136
+ accounting,
137
+ utilities,
138
+ repairs,
139
+ maintenance,
140
+ acquisition,
141
+ sale_costs,
142
+ interest_rate,
143
+ loan_principle,
144
+ capital_expenditures,
145
+ capital_expenditure_loans,
146
+ earned_interest
147
+ ).cash_flow_before_taxes
148
+ </code>
149
+
150
+
151
+ - cash_flow_after_taxes
152
+ <code>
153
+ RealEstateFinance::CashFlowAfterTaxes.new(
154
+ monthly_income,
155
+ vacancies,
156
+ non_payments,
157
+ taxes,
158
+ mortgage_interest,
159
+ marketing,
160
+ advertising,
161
+ management,
162
+ legal,
163
+ accounting,
164
+ utilities,
165
+ repairs,
166
+ maintenance,
167
+ acquisition,
168
+ sale_costs,
169
+ interest_rate,
170
+ loan_principle,
171
+ capital_expenditures,
172
+ capital_expenditure_loans,
173
+ earned_interest,
174
+ state_income_tax,
175
+ federal_income_tax
176
+ ).cash_flow_after_taxes
177
+ </code>
178
+
179
+
180
+ - break_even_ratio
181
+ <code>
182
+ RealEstateFinance::BreakEvenRatio.new(
183
+ interest_rate,
184
+ loan_principle,
185
+ marketing,
186
+ advertising,
187
+ management,
188
+ legal,
189
+ accounting,
190
+ utilities,
191
+ repairs,
192
+ maintenance,
193
+ monthly_income,
194
+ estimated_loss_percentage
195
+ ).break_even_ratio
196
+ </code>
197
+
198
+
199
+ - return_on_equity
200
+ <code>
201
+ RealEstateFinance::ReturnOnEquity.new(
202
+ monthly_income,
203
+ vacancies,
204
+ non_payments,
205
+ taxes,
206
+ mortgage_interest,
207
+ marketing,
208
+ advertising,
209
+ management,
210
+ legal,
211
+ accounting,
212
+ utilities,
213
+ repairs,
214
+ maintenance,
215
+ acquisition,
216
+ sale_costs,
217
+ interest_rate,
218
+ loan_principle,
219
+ capital_expenditures,
220
+ capital_expenditure_loans,
221
+ earned_interest,
222
+ state_income_tax,
223
+ federal_income_tax,
224
+ principle_invested
225
+ ).return_on_equity
226
+ </code>
227
+
228
+ ## Development
229
+
230
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
231
+
232
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
233
+
234
+ ## Contributing
235
+
236
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/real_estate_finance.
237
+
238
+
239
+ ## License
240
+
241
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
242
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "real_estate_finance"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ require "real_estate_finance/version"
2
+
3
+ module RealEstateFinance
4
+ require_relative "real_estate_finance/gross_potential_income"
5
+ require_relative "real_estate_finance/net_operating_income"
6
+ require_relative "real_estate_finance/gross_rental_multiplier"
7
+ require_relative "real_estate_finance/estimated_property_value_from_grm"
8
+ require_relative "real_estate_finance/gross_operating_income"
9
+ require_relative "real_estate_finance/capitalization_rate"
10
+ require_relative "real_estate_finance/estimated_property_value_from_cap_rate"
11
+ require_relative "real_estate_finance/cash_flow_before_taxes"
12
+ require_relative "real_estate_finance/cash_flow_after_taxes"
13
+ require_relative "real_estate_finance/break_even_ratio"
14
+ require_relative "real_estate_finance/return_on_equity"
15
+ end
@@ -0,0 +1,39 @@
1
+ module RealEstateFinance
2
+ class BreakEvenRatio
3
+
4
+ attr_reader :interest_rate, :loan_principle, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :monthly_income, :estimated_loss_percentage
5
+
6
+ def initialize(interest_rate, loan_principle, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, monthly_income, estimated_loss_percentage)
7
+ @interest_rate = interest_rate
8
+ @loan_principle = loan_principle
9
+ @marketing = marketing
10
+ @advertising = advertising
11
+ @management = management
12
+ @legal = legal
13
+ @accounting = accounting
14
+ @utilities = utilities
15
+ @repairs = repairs
16
+ @maintenance = maintenance
17
+ @monthly_income = monthly_income
18
+ @estimated_loss_percentage = estimated_loss_percentage
19
+ end
20
+
21
+ def break_even_ratio
22
+ interest_rate_formatted = sprintf("%0.02f", @interest_rate / (100)).to_f
23
+ interest_dollar_amount = sprintf("%0.02f", (interest_rate_formatted * @loan_principle) + @loan_principle).to_f
24
+
25
+ credit_losses = [@marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance]
26
+ operating_expenses = credit_losses.reduce(:+)
27
+
28
+ total_expenses = sprintf("%0.02f", (interest_dollar_amount + operating_expenses)).to_f
29
+
30
+ agi = sprintf("%0.02f", (@monthly_income * 12)).to_f
31
+ loss_percentage = sprintf("%0.02f", @estimated_loss_percentage.to_i / (100.to_f)).to_f
32
+
33
+ goi = sprintf("%0.02f", (agi * loss_percentage)).to_f
34
+
35
+ ber = sprintf("%0.02f", (total_expenses / (goi))).to_f
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ module RealEstateFinance
2
+ class CapitalizationRate
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs, :sale_earned
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs, sale_earned)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ @sale_earned = sale_earned
23
+ end
24
+
25
+ def capitalization_rate
26
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
27
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
28
+ total_expenses = credit_losses.reduce(:+)
29
+ expenses = sprintf("%0.02f", total_expenses).to_f
30
+ noi = gpi - expenses
31
+ cap_rate = sprintf("%0.03f", (noi/(@sale_earned))).to_f
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,45 @@
1
+ module RealEstateFinance
2
+ class CashFlowAfterTaxes
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs, :interest_rate, :loan_principle, :capital_expenditures, :capital_expenditure_loans, :earned_interest, :state_income_tax, :federal_income_tax
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs, interest_rate, loan_principle, capital_expenditures, capital_expenditure_loans, earned_interest, state_income_tax, federal_income_tax)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ @interest_rate = interest_rate
23
+ @loan_principle = loan_principle
24
+ @capital_expenditures = capital_expenditures
25
+ @capital_expenditure_loans = capital_expenditure_loans
26
+ @earned_interest = earned_interest
27
+ @state_income_tax = state_income_tax
28
+ @federal_income_tax = federal_income_tax
29
+ end
30
+
31
+ def cash_flow_after_taxes
32
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
33
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
34
+ total_expenses = credit_losses.reduce(:+)
35
+ expenses = sprintf("%0.02f", total_expenses).to_f
36
+ noi = gpi - expenses
37
+
38
+ credit_losses = [@capital_expenditure_loans, @capital_expenditures, sprintf("%0.02f", (@interest_rate / (100))).to_f, @loan_principle]
39
+ credit_surpluses = @earned_interest
40
+ cfbt = sprintf("%0.02f", ((noi - credit_losses.reduce(:+)) + credit_surpluses)).to_f
41
+ cfat = sprintf("%0.02f", (cfbt - sprintf("%0.02f", (@state_income_tax + @federal_income_tax)).to_f)).to_f
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ module RealEstateFinance
2
+ class CashFlowBeforeTaxes
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs, :interest_rate, :loan_principle, :capital_expenditures, :capital_expenditure_loans, :earned_interest
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs, interest_rate, loan_principle, capital_expenditures, capital_expenditure_loans, earned_interest)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ @interest_rate = interest_rate
23
+ @loan_principle = loan_principle
24
+ @capital_expenditures = capital_expenditures
25
+ @capital_expenditure_loans = capital_expenditure_loans
26
+ @earned_interest = earned_interest
27
+ end
28
+
29
+ def cash_flow_before_taxes
30
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
31
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
32
+ total_expenses = credit_losses.reduce(:+)
33
+ expenses = sprintf("%0.02f", total_expenses).to_f
34
+ noi = gpi - expenses
35
+
36
+ credit_losses = [@capital_expenditure_loans, @capital_expenditures, sprintf("%0.02f", (@interest_rate / (100))).to_f, @loan_principle]
37
+ credit_surpluses = @earned_interest
38
+ cfbt = sprintf("%0.02f", ((noi - credit_losses.reduce(:+)) + credit_surpluses)).to_f
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,36 @@
1
+ module RealEstateFinance
2
+ class EstimatedPropertyValueFromCapRate
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs, :sale_earned
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs, sale_earned)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ @sale_earned = sale_earned
23
+ end
24
+
25
+ def estimated_property_value_from_cap_rate
26
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
27
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
28
+ total_expenses = credit_losses.reduce(:+)
29
+ expenses = sprintf("%0.02f", total_expenses).to_f
30
+ noi = gpi - expenses
31
+ cap_rate = sprintf("%0.03f", (noi/(@sale_earned))).to_f
32
+ estimated_value = sprintf("%0.02f", (noi / (cap_rate))).to_f
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ module RealEstateFinance
2
+ class EstimatedPropertyValueFromGRM
3
+
4
+ attr_reader :market_value, :monthly_income
5
+
6
+ def initialize(market_value, monthly_income)
7
+ @market_value = market_value
8
+ @monthly_income = monthly_income
9
+ end
10
+
11
+ def estimated_property_value_from_grm
12
+ annual_gross_potential_income = sprintf("%0.02f", (@monthly_income * 12)).to_f
13
+ calculation = @market_value.to_i / (annual_gross_potential_income)
14
+ grm = sprintf("%0.03f", calculation).to_f
15
+ property_value_by_grm = sprintf("%0.02f", (grm * annual_gross_potential_income)).to_f
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module RealEstateFinance
2
+ class GrossOperatingIncome
3
+
4
+ attr_reader :monthly_income, :estimated_loss_percentage
5
+
6
+ def initialize(monthly_income, estimated_loss_percentage)
7
+ @monthly_income = monthly_income
8
+ @estimated_loss_percentage = estimated_loss_percentage
9
+ end
10
+
11
+ def gross_operating_income
12
+ agi = sprintf("%0.02f", (@monthly_income * 12)).to_f
13
+ loss_percentage = sprintf("%0.02f", @estimated_loss_percentage.to_i / (100.to_f)).to_f
14
+ estimated_loss = sprintf("%0.02f", (agi * loss_percentage)).to_f
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module RealEstateFinance
2
+ class GrossPotentialIncome
3
+
4
+ attr_reader :monthly_income
5
+
6
+ def initialize(monthly_income)
7
+ @monthly_income = monthly_income
8
+ end
9
+
10
+ def gross_potential_income
11
+ sprintf("%0.02f", (@monthly_income * 12)).to_f
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module RealEstateFinance
2
+ class GrossRentalMultiplier
3
+
4
+ attr_reader :market_value, :monthly_income
5
+
6
+ def initialize(market_value, monthly_income)
7
+ @market_value = market_value
8
+ @monthly_income = monthly_income
9
+ end
10
+
11
+ def gross_rental_multiplier
12
+ annual_gross_potential_income = sprintf("%0.02f", (@monthly_income * 12)).to_f
13
+ calculation = @market_value.to_i / (annual_gross_potential_income)
14
+ sprintf("%0.03f", calculation).to_f
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ module RealEstateFinance
2
+ class NetOperatingIncome
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ end
23
+
24
+ def net_operating_income
25
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
26
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
27
+ total_expenses = credit_losses.reduce(:+)
28
+ expenses = sprintf("%0.02f", total_expenses).to_f
29
+ noi = gpi - expenses
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ module RealEstateFinance
2
+ class ReturnOnEquity
3
+
4
+ attr_reader :monthly_income, :vacancies, :non_payments, :taxes, :mortgage_interest, :marketing, :advertising, :management, :legal, :accounting, :utilities, :repairs, :maintenance, :acquisition, :sale_costs, :interest_rate, :loan_principle, :capital_expenditures, :capital_expenditure_loans, :earned_interest, :state_income_tax, :federal_income_tax, :principle_invested
5
+
6
+ def initialize(monthly_income, vacancies, non_payments, taxes, mortgage_interest, marketing, advertising, management, legal, accounting, utilities, repairs, maintenance, acquisition, sale_costs, interest_rate, loan_principle, capital_expenditures, capital_expenditure_loans, earned_interest, state_income_tax, federal_income_tax, principle_invested)
7
+ @monthly_income = monthly_income
8
+ @vacancies = vacancies
9
+ @non_payments = non_payments
10
+ @taxes = taxes
11
+ @mortgage_interest = mortgage_interest
12
+ @marketing = marketing
13
+ @advertising = advertising
14
+ @management = management
15
+ @legal = legal
16
+ @accounting = accounting
17
+ @utilities = utilities
18
+ @repairs = repairs
19
+ @maintenance = maintenance
20
+ @acquisition = acquisition
21
+ @sale_costs = sale_costs
22
+ @interest_rate = interest_rate
23
+ @loan_principle = loan_principle
24
+ @capital_expenditures = capital_expenditures
25
+ @capital_expenditure_loans = capital_expenditure_loans
26
+ @earned_interest = earned_interest
27
+ @state_income_tax = state_income_tax
28
+ @federal_income_tax = federal_income_tax
29
+ @principle_invested = principle_invested
30
+ end
31
+
32
+ def return_on_equity
33
+ gpi = sprintf("%0.02f", (@monthly_income * 12)).to_f
34
+ credit_losses = [@vacancies, @non_payments, @taxes, @mortgage_interest, @marketing, @advertising, @management, @legal, @accounting, @utilities, @repairs, @maintenance, @acquisition, @sale_costs]
35
+ total_expenses = credit_losses.reduce(:+)
36
+ expenses = sprintf("%0.02f", total_expenses).to_f
37
+ noi = gpi - expenses
38
+
39
+ credit_losses = [@capital_expenditure_loans, @capital_expenditures, sprintf("%0.02f", (@interest_rate / (100))).to_f, @loan_principle]
40
+ credit_surpluses = @earned_interest
41
+ cfbt = sprintf("%0.02f", ((noi - credit_losses.reduce(:+)) + credit_surpluses)).to_f
42
+ cfat = sprintf("%0.02f", (cfbt - sprintf("%0.02f", (@state_income_tax + @federal_income_tax)).to_f)).to_f
43
+ roq = sprintf("%0.02f", (cfat + @principle_invested)).to_f
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module RealEstateFinance
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'real_estate_finance/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "real_estate_finance"
8
+ spec.version = RealEstateFinance::VERSION
9
+ spec.authors = ["Alexander Aleksanyan"]
10
+ spec.email = ["alex1100.software@gmail.com"]
11
+
12
+ spec.summary = %q{Real Estate Finance Formulas/Calculations right out of the box.}
13
+ spec.description = %q{Real Estate Finance Formulas/Calculations right out of the box.}
14
+ spec.homepage = "https://github.com/Alex1100/real_estate_finance"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "guard"
37
+ spec.add_development_dependency "guard-rspec"
38
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: real_estate_finance
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Aleksanyan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Real Estate Finance Formulas/Calculations right out of the box.
84
+ email:
85
+ - alex1100.software@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - Guardfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/real_estate_finance.rb
100
+ - lib/real_estate_finance/break_even_ratio.rb
101
+ - lib/real_estate_finance/capitalization_rate.rb
102
+ - lib/real_estate_finance/cash_flow_after_taxes.rb
103
+ - lib/real_estate_finance/cash_flow_before_taxes.rb
104
+ - lib/real_estate_finance/estimated_property_value_from_cap_rate.rb
105
+ - lib/real_estate_finance/estimated_property_value_from_grm.rb
106
+ - lib/real_estate_finance/gross_operating_income.rb
107
+ - lib/real_estate_finance/gross_potential_income.rb
108
+ - lib/real_estate_finance/gross_rental_multiplier.rb
109
+ - lib/real_estate_finance/net_operating_income.rb
110
+ - lib/real_estate_finance/return_on_equity.rb
111
+ - lib/real_estate_finance/version.rb
112
+ - real_estate_finance.gemspec
113
+ homepage: https://github.com/Alex1100/real_estate_finance
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.6.12
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Real Estate Finance Formulas/Calculations right out of the box.
137
+ test_files: []