appraisermetrics_report_service 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/appraisermetrics_report_service.gemspec +26 -0
- data/config/static_text.yml +44 -0
- data/lib/appraisermetrics_report_service.rb +8 -0
- data/lib/appraisermetrics_report_service/version.rb +3 -0
- data/lib/closed_sale.rb +706 -0
- data/lib/eval_report.rb +1192 -0
- data/lib/report_utils.rb +219 -0
- data/spec/lib/closed_sale_spec.rb +626 -0
- data/spec/lib/eval_report_spec.rb +799 -0
- data/spec/lib/report_utils_spec.rb +213 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/test_data/images/ag_sales.jpg +0 -0
- data/spec/test_data/images/profile1.png +0 -0
- data/spec/test_data/images/property_pic1.png +0 -0
- data/spec/test_data/images/property_pic2.png +0 -0
- data/spec/test_data/images/property_pic3.png +0 -0
- data/spec/test_data/images/property_pic4.png +0 -0
- data/spec/test_data/images/regional1.jpg +0 -0
- data/spec/test_data/images/regional2.jpg +0 -0
- data/spec/test_data/images/subject1.jpg +0 -0
- data/spec/test_data/images/subject2.jpg +0 -0
- data/spec/test_data/images/subject3.jpg +0 -0
- data/spec/test_data/images/subject4.jpg +0 -0
- data/spec/test_data/images/test_logo.png +0 -0
- data/spec/test_data/images/topo1.jpg +0 -0
- data/spec/test_data/images/topo2.jpg +0 -0
- data/spec/test_data/sampler.rb +1404 -0
- metadata +208 -0
data/lib/report_utils.rb
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
module ReportUtils
|
2
|
+
|
3
|
+
def static_strings
|
4
|
+
text_blocks = {}
|
5
|
+
static_strings = YAML.load_file('./config/static_text.yml')
|
6
|
+
static_strings.each {|k, v| text_blocks[k.to_sym] = v}
|
7
|
+
return text_blocks
|
8
|
+
end
|
9
|
+
module_function :static_strings
|
10
|
+
|
11
|
+
def moneymaker(money_hash, without_cents) # ({cents: 12345, currency_iso: "USD"}, boolean) # DRY currency string generation
|
12
|
+
if money_hash
|
13
|
+
m = Money.new(money_hash[:cents], money_hash[:currency_iso])
|
14
|
+
else
|
15
|
+
m = Money.new(0, "USD")
|
16
|
+
end
|
17
|
+
|
18
|
+
m.format(no_cents: without_cents)
|
19
|
+
end
|
20
|
+
|
21
|
+
def datemaker(date_string) # takes a string string value, avoid parse errors by checking for nil
|
22
|
+
if date_string
|
23
|
+
begin
|
24
|
+
ds = Date.parse(date_string)
|
25
|
+
rescue ArgumentError => ex
|
26
|
+
end
|
27
|
+
end
|
28
|
+
ds ||= ''
|
29
|
+
return ds
|
30
|
+
end
|
31
|
+
|
32
|
+
def no_nil_array(array_hash) # check for nodes for arrays that might be nil, return empty array
|
33
|
+
array_hash ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
def no_nil_number(my_num) # check for nil nodes to avoid typerrors and NoMethod
|
37
|
+
my_num ||= 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def no_nil_string(my_string) # check for nil befor calling methods on it
|
41
|
+
my_string ||= ""
|
42
|
+
end
|
43
|
+
|
44
|
+
def parallel_text(static, dyn, indent_distance) # DRY parallel text gen method for text in the form: "Some Title:" "Some Data"
|
45
|
+
float do
|
46
|
+
text static, style: :bold
|
47
|
+
end
|
48
|
+
|
49
|
+
indent(indent_distance) do
|
50
|
+
text dyn
|
51
|
+
end
|
52
|
+
end
|
53
|
+
module_function :parallel_text
|
54
|
+
|
55
|
+
def average_primary_land_val(comp_values) # averages an array of floats
|
56
|
+
sum = comp_values.inject(:+)
|
57
|
+
ave = sum ? sum / comp_values.count : 0
|
58
|
+
return Money.new(ave * 100, 'USD')
|
59
|
+
end
|
60
|
+
module_function :average_primary_land_val
|
61
|
+
|
62
|
+
def median_primary_land_val(comp_values) # gets median value for an array of floats
|
63
|
+
sorted_array = comp_values.sort
|
64
|
+
length = sorted_array.length
|
65
|
+
|
66
|
+
median = sorted_array.any? ? (sorted_array[(length - 1) / 2] + sorted_array[length / 2]) / 2.0 : 0
|
67
|
+
return Money.new(median * 100, 'USD')
|
68
|
+
end
|
69
|
+
module_function :median_primary_land_val
|
70
|
+
|
71
|
+
def maximum_primary_land_val(comp_values) # gets max value for array of floats
|
72
|
+
max = comp_values.any? ? comp_values.max : 0
|
73
|
+
return Money.new(max * 100, 'USD')
|
74
|
+
end
|
75
|
+
module_function :maximum_primary_land_val
|
76
|
+
|
77
|
+
def minimum_primary_land_val(comp_values) # gets min value for array of floats
|
78
|
+
min = comp_values.any? ? comp_values.min : 0
|
79
|
+
return Money.new(min * 100, 'USD')
|
80
|
+
end
|
81
|
+
module_function :minimum_primary_land_val
|
82
|
+
|
83
|
+
def flip_improvements_array(improv_array)
|
84
|
+
type, size, unit_of_measure, foundation, const_class = ["Type"], ["Size"], ["Unit of Measure"], ["Foundation"], ["Const. Class"]
|
85
|
+
floor, const_quality, cond_utility, year_built = ["Floor"], ["Const. Quality"], ["Cond Utility"], ["Year Built"]
|
86
|
+
total_econ_al, eff_age, remaining_al, rcn, def_maint = ["Total Economic AL"], ["Remaining AL:"], ["RCN:"], ["Deferred Maint:"], ["% Physical Deprec."]
|
87
|
+
phys_dep, func_dep, economic, total_cont_val = ["% Physical Deprec."], ["% Functional Deprec."], ["% Economic"], ["Total Cont. Value:"]
|
88
|
+
|
89
|
+
if improv_array && improv_array.any?
|
90
|
+
improv_array.each do |i|
|
91
|
+
type.push("#{i[:improvtype]}")
|
92
|
+
size.push("#{i[:unitsize]}")
|
93
|
+
unit_of_measure.push("#{i[:unitdescr]}")
|
94
|
+
foundation.push("#{i[:foundation]}")
|
95
|
+
const_class.push("#{i[:constrclass]}")
|
96
|
+
floor.push("#{i[:floor]}")
|
97
|
+
const_quality.push("#{i[:qaulityconstr]}")
|
98
|
+
cond_utility.push("#{i[:condition]}")
|
99
|
+
year_built.push("#{i[:yearbuilt]}")
|
100
|
+
total_econ_al.push("#{i[:totalecoage]}")
|
101
|
+
eff_age.push("#{i[:effage]}")
|
102
|
+
remaining_al.push("#{no_nil_number(i[:totalecoage]) - no_nil_number(i[:effage])}")
|
103
|
+
rcn.push(moneymaker(i[:rplccost], true))
|
104
|
+
def_maint.push("#{moneymaker(i[:deffmaintenance], false)}")
|
105
|
+
|
106
|
+
eco_age = no_nil_number(i[:totalecoage])
|
107
|
+
if eco_age == 0
|
108
|
+
phys_dep.push("undef")
|
109
|
+
else
|
110
|
+
phys_dep.push("#{no_nil_number(i[:effage]) / eco_age}")
|
111
|
+
end
|
112
|
+
|
113
|
+
func_dep.push("#{i[:fnctldeprication]}")
|
114
|
+
economic.push("#{i[:extdeprication]}")
|
115
|
+
total_cont_val.push("#{moneymaker(i[:depval], false)}")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
parsed_array = [
|
120
|
+
[{content: "Improvements", colspan: 8}],
|
121
|
+
%w(Description Imprv.1 Imprv.2 Imprv.3 Imprv.4 Imprv.5 Imprv.6 Imprv.7)
|
122
|
+
]
|
123
|
+
parsed_array.push(type, size, unit_of_measure, foundation, const_class, floor, const_quality, cond_utility, year_built,
|
124
|
+
total_econ_al, eff_age, remaining_al, rcn, def_maint, phys_dep, func_dep, economic, total_cont_val)
|
125
|
+
# this method creates a 2 dimensional array to pass in to prawn table
|
126
|
+
# it is necessary because of the reversed axis of the improvements table
|
127
|
+
# there is likely a cleaner way to do this, but any solution should ensure a predictable array to pass to a prawn table
|
128
|
+
# an array should contain 8 elements that can include nil or "" if such an attribute does not exist.
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.conditional_externs_array(doc)
|
132
|
+
# the array that will be returned and used by the prawn table
|
133
|
+
full_array = [
|
134
|
+
[{content: "Externalities, Wind Power Generation, Transmission Towers", colspan: 4}]
|
135
|
+
]
|
136
|
+
|
137
|
+
# row 1, will populate 3rd and 4th cells conditionally
|
138
|
+
externs_array = [
|
139
|
+
{content: "Are there any past uses of the property that may have
|
140
|
+
created hazardous waste contamination of the property or its groundwater? If yes, describe:", colspan: 2}
|
141
|
+
]
|
142
|
+
|
143
|
+
# push affected by into externs array
|
144
|
+
affected_by = doc[:property_affectedby]
|
145
|
+
if affected_by && affected_by.any?
|
146
|
+
externs_array.push("Description of Externalities that affect(s) this property:", affected_by.join(", "))
|
147
|
+
end
|
148
|
+
|
149
|
+
# conditional push of hazards and/or problems if exist
|
150
|
+
hazards_and_problems = []
|
151
|
+
if doc[:has_hazardous_waste] == "Yes"
|
152
|
+
hazards_and_problems.push({content: doc[:hazard_descr], colspan: 2})
|
153
|
+
else
|
154
|
+
hazards_and_problems.push({content: "No", colspan: 2})
|
155
|
+
end
|
156
|
+
|
157
|
+
# check various fields for environmental or other problems
|
158
|
+
problems = []
|
159
|
+
problems.push(doc[:problem_descr], doc[:env_problems], doc[:env_problem_descr])
|
160
|
+
if problems && problems.any?
|
161
|
+
hazards_and_problems.push("Description of problems, issues or resolve:", problems.join(". "))
|
162
|
+
end
|
163
|
+
|
164
|
+
# conditional push of tower and wind info
|
165
|
+
towers_and_wind_type = []
|
166
|
+
ttowers = doc[:ttowers]
|
167
|
+
if ttowers && ttowers.any?
|
168
|
+
towers_and_wind_type.push("Type of Transmission Tower on Property:", ttowers.join(", "))
|
169
|
+
end
|
170
|
+
|
171
|
+
wind = doc[:windgeneratortype]
|
172
|
+
if wind && wind.any?
|
173
|
+
towers_and_wind_type.push("Wind Power Generation Type:", wind.join(", "))
|
174
|
+
end
|
175
|
+
|
176
|
+
#conditional push of tower income and wind speed
|
177
|
+
tt_income_and_wind_speed = []
|
178
|
+
if doc[:tt_annual_income]
|
179
|
+
tt_income_and_wind_speed.push("Annual net income from Transmission Tower Contracts:", doc[:tt_annual_income])
|
180
|
+
end
|
181
|
+
|
182
|
+
if doc[:windspeed]
|
183
|
+
tt_income_and_wind_speed.push("Wind Speed Class:", doc[:windspeed])
|
184
|
+
end
|
185
|
+
|
186
|
+
# conditional push of transmission tower comments and number of wind gen towers
|
187
|
+
tt_comments_and_wind_towers = []
|
188
|
+
if doc[:transtower_comments]
|
189
|
+
tt_comments_and_wind_towers.push("Transmission Tower Comments:", doc[:transtower_comments])
|
190
|
+
end
|
191
|
+
|
192
|
+
if doc[:num_of_gentowers]
|
193
|
+
tt_comments_and_wind_towers.push("Number of Generation Towers:", doc[:num_of_gentowers])
|
194
|
+
end
|
195
|
+
|
196
|
+
# conditional push of tower info
|
197
|
+
tower_height = ["", ""]
|
198
|
+
if doc[:avgtowerhight]
|
199
|
+
tower_height.push("Average Height of Generation Towers:", doc[:avgtowerhight])
|
200
|
+
end
|
201
|
+
|
202
|
+
wind_income = ["", ""]
|
203
|
+
if doc[:windgenincome]
|
204
|
+
wind_income.push("Net Annual Income Generate from Wind Generation Towers:", doc[:windgenincome])
|
205
|
+
end
|
206
|
+
|
207
|
+
wind_gen_comment = ["", ""]
|
208
|
+
if doc[:windgen_comment]
|
209
|
+
wind_gen_comment.push("Wind Generation Comments:", doc[:windgen_comment])
|
210
|
+
end
|
211
|
+
|
212
|
+
# push all subarrays into main array and return
|
213
|
+
full_array.push(externs_array, hazards_and_problems, towers_and_wind_type,
|
214
|
+
tt_income_and_wind_speed, tt_comments_and_wind_towers, tower_height, wind_income, wind_gen_comment)
|
215
|
+
|
216
|
+
return full_array
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
@@ -0,0 +1,626 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'closed_sale class' do
|
4
|
+
describe 'meta data table' do # meta data
|
5
|
+
context 'keys present' do
|
6
|
+
before :each do
|
7
|
+
@pdf = ClosedSale.new do
|
8
|
+
@rep = Sampler.get_comp2 # using record 1054 for tests
|
9
|
+
meta_data
|
10
|
+
end
|
11
|
+
@meta_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'renders static data' do
|
15
|
+
expect(@meta_content).to include('Record Created By')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'renders the meta data table if keys are present' do
|
19
|
+
expect(@meta_content).to include('1054')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'keys missing' do
|
24
|
+
it 'renders static content' do
|
25
|
+
@pdf = ClosedSale.new do
|
26
|
+
@rep = {foo: 'bar'}
|
27
|
+
meta_data
|
28
|
+
end
|
29
|
+
|
30
|
+
@meta_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
31
|
+
expect(@meta_content).to include('Record Created By')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'image' do
|
37
|
+
it 'renders the text "No image" if there are no images to display' do
|
38
|
+
@pdf = ClosedSale.new do
|
39
|
+
@rep = {foo: 'bar'}
|
40
|
+
@property_images = []
|
41
|
+
profile_image
|
42
|
+
end
|
43
|
+
|
44
|
+
@image_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
45
|
+
expect(@image_content).to include('No Image')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'renders the profile image if present' do
|
49
|
+
@pdf = ClosedSale.new do
|
50
|
+
@rep = {foo: 'bar'}
|
51
|
+
@property_images = ['./spec/test_data/images/profile1.png']
|
52
|
+
profile_image
|
53
|
+
end
|
54
|
+
|
55
|
+
@image_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
56
|
+
expect(@image_content).to include('')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'land classification' do
|
61
|
+
context 'with keys' do
|
62
|
+
before :each do
|
63
|
+
@pdf = ClosedSale.new do
|
64
|
+
@rep = Sampler.get_comp2
|
65
|
+
land_classification
|
66
|
+
end
|
67
|
+
@land_class_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
68
|
+
end
|
69
|
+
it 'renders static content' do
|
70
|
+
expect(@land_class_content).to include('Land Class')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'renders dynamic content from keys' do
|
74
|
+
expect(@land_class_content).to include('$7,500')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'without keys' do
|
79
|
+
it 'renders static content' do
|
80
|
+
@pdf = ClosedSale.new do
|
81
|
+
@rep = {foo: 'bar'}
|
82
|
+
land_classification
|
83
|
+
end
|
84
|
+
@land_class_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
85
|
+
expect(@land_class_content).to include('Land Class')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'cash flow' do
|
91
|
+
context 'with keys' do
|
92
|
+
before :each do
|
93
|
+
@pdf = ClosedSale.new do
|
94
|
+
@rep = Sampler.get_comp2
|
95
|
+
cash_flow
|
96
|
+
end
|
97
|
+
@cash_flow_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'renders static content' do
|
101
|
+
expect(@cash_flow_content).to include('Cash Flow - Production Analysis')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'renders dynamic content from keys' do
|
105
|
+
expect(@cash_flow_content).to include('$600.00')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'without keys' do
|
110
|
+
it 'renders static content' do
|
111
|
+
@pdf = ClosedSale.new do
|
112
|
+
@rep = {foo: 'bar'}
|
113
|
+
cash_flow
|
114
|
+
end
|
115
|
+
@cash_flow_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
116
|
+
expect(@cash_flow_content).to include('Cash Flow - Production Analysis')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'comments' do
|
122
|
+
context 'with keys' do
|
123
|
+
before :each do
|
124
|
+
@pdf = ClosedSale.new do
|
125
|
+
@rep = Sampler.get_comp2
|
126
|
+
comments
|
127
|
+
end
|
128
|
+
@comments_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'renders static content' do
|
132
|
+
expect(@comments_content).to include('Comments')
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'renders dynamic content from keys' do
|
136
|
+
expect(@comments_content).to include('Farmer retiring')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'without keys' do
|
141
|
+
it 'renders static content' do
|
142
|
+
@pdf = ClosedSale.new do
|
143
|
+
@rep = {foo: 'bar'}
|
144
|
+
comments
|
145
|
+
end
|
146
|
+
@comments_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
147
|
+
expect(@comments_content).to include('Comments')
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'property class' do
|
153
|
+
context 'with keys' do
|
154
|
+
before :each do
|
155
|
+
@pdf = ClosedSale.new do
|
156
|
+
@rep = Sampler.get_comp2
|
157
|
+
property_class
|
158
|
+
end
|
159
|
+
@property_class_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'renders static content' do
|
163
|
+
expect(@property_class_content).to include('Transaction Type')
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'renders dynamic content from keys' do
|
167
|
+
expect(@property_class_content).to include('Apple and Potato Farm')
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'without keys' do
|
172
|
+
it 'renders static content' do
|
173
|
+
@pdf = ClosedSale.new do
|
174
|
+
@rep = {foo: 'bar'}
|
175
|
+
property_class
|
176
|
+
end
|
177
|
+
@property_class_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
178
|
+
expect(@property_class_content).to include('Transaction Type')
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe 'property type and address' do
|
184
|
+
context 'with keys' do
|
185
|
+
before :each do
|
186
|
+
@pdf = ClosedSale.new do
|
187
|
+
@rep = Sampler.get_comp2
|
188
|
+
property_type_and_address
|
189
|
+
end
|
190
|
+
@property_type_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'renders static content' do
|
194
|
+
expect(@property_type_content).to include('Property Type and Address')
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'renders dynamic content from keys' do
|
198
|
+
expect(@property_type_content).to include('Apple')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context 'without keys' do
|
203
|
+
it 'renders static content' do
|
204
|
+
@pdf = ClosedSale.new do
|
205
|
+
@rep = {foo: 'bar'}
|
206
|
+
property_type_and_address
|
207
|
+
end
|
208
|
+
@property_type_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
209
|
+
expect(@property_type_content).to include('Property Type and Address')
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe 'transaction summary' do
|
215
|
+
context 'with keys' do
|
216
|
+
before :each do
|
217
|
+
@pdf = ClosedSale.new do
|
218
|
+
@rep = Sampler.get_comp2
|
219
|
+
transaction_summary
|
220
|
+
end
|
221
|
+
@transaction_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'renders static content' do
|
225
|
+
expect(@transaction_content).to include('Sale Price')
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'renders dynamic content from keys' do
|
229
|
+
expect(@transaction_content).to include('950.00')
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'without keys' do
|
234
|
+
it 'renders static content' do
|
235
|
+
@pdf = ClosedSale.new do
|
236
|
+
@rep = {foo: 'bar'}
|
237
|
+
transaction_summary
|
238
|
+
end
|
239
|
+
@transaction_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
240
|
+
expect(@transaction_content).to include('Sale Price')
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe 'physical overview' do
|
246
|
+
context 'with keys' do
|
247
|
+
before :each do
|
248
|
+
@pdf = ClosedSale.new do
|
249
|
+
@rep = Sampler.get_comp2
|
250
|
+
physical_overview
|
251
|
+
end
|
252
|
+
@physical_overview_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'renders static content' do
|
256
|
+
expect(@physical_overview_content).to include('Physical Overview')
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'renders dynamic content from keys' do
|
260
|
+
expect(@physical_overview_content).to include('Loam')
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'without keys' do
|
265
|
+
it 'renders static content' do
|
266
|
+
@pdf = ClosedSale.new do
|
267
|
+
@rep = {foo: 'bar'}
|
268
|
+
physical_overview
|
269
|
+
end
|
270
|
+
@physical_overview_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
271
|
+
expect(@physical_overview_content).to include('Physical Overview')
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe 'income expense' do
|
277
|
+
context 'with keys' do
|
278
|
+
before :each do
|
279
|
+
@pdf = ClosedSale.new do
|
280
|
+
@rep = Sampler.get_comp2
|
281
|
+
income_expense
|
282
|
+
end
|
283
|
+
@income_expense_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'renders static content' do
|
287
|
+
expect(@income_expense_content).to include('Farm')
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'renders dynamic content from keys' do
|
291
|
+
expect(@income_expense_content).to include('$698,000')
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
context 'without keys' do
|
296
|
+
it 'renders static content' do
|
297
|
+
@pdf = ClosedSale.new do
|
298
|
+
@rep = {foo: 'bar'}
|
299
|
+
income_expense
|
300
|
+
end
|
301
|
+
@income_expense_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
302
|
+
expect(@income_expense_content).to include('Farm')
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe 'legal transaction' do
|
308
|
+
context 'with keys' do
|
309
|
+
before :each do
|
310
|
+
@pdf = ClosedSale.new do
|
311
|
+
@rep = Sampler.get_comp2
|
312
|
+
legal_transaction
|
313
|
+
end
|
314
|
+
@legal_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'renders static content' do
|
318
|
+
expect(@legal_content).to include('Legal/Transaction Detail')
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'renders dynamic content from keys' do
|
322
|
+
expect(@legal_content).to include('06750')
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
context 'without keys' do
|
327
|
+
it 'renders static content' do
|
328
|
+
@pdf = ClosedSale.new do
|
329
|
+
@rep = {foo: 'bar'}
|
330
|
+
legal_transaction
|
331
|
+
end
|
332
|
+
@legal_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
333
|
+
expect(@legal_content).to include('Legal/Transaction Detail')
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
describe 'transaction history' do
|
339
|
+
context 'with keys' do
|
340
|
+
before :each do
|
341
|
+
@pdf = ClosedSale.new do
|
342
|
+
@rep = Sampler.get_comp2
|
343
|
+
transaction_history
|
344
|
+
end
|
345
|
+
@transaction_history_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'renders static content' do
|
349
|
+
expect(@transaction_history_content).to include('Historic')
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'renders dynamic content from keys' do
|
353
|
+
expect(@transaction_history_content).to include('Prior Transfer of Title')
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
context 'without keys' do
|
358
|
+
it 'renders static content' do
|
359
|
+
@pdf = ClosedSale.new do
|
360
|
+
@rep = {foo: 'bar'}
|
361
|
+
transaction_history
|
362
|
+
end
|
363
|
+
@transaction_history_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
364
|
+
expect(@transaction_history_content).to include('Historic')
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe 'utilities' do
|
370
|
+
context 'with keys' do
|
371
|
+
before :each do
|
372
|
+
@pdf = ClosedSale.new do
|
373
|
+
@rep = Sampler.get_comp2
|
374
|
+
utilities
|
375
|
+
end
|
376
|
+
@utilities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'renders static content' do
|
380
|
+
expect(@utilities_content).to include('Utility Description')
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'renders dynamic content from keys' do
|
384
|
+
expect(@utilities_content).to include('Electricity')
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
context 'without keys' do
|
389
|
+
it 'renders static content' do
|
390
|
+
@pdf = ClosedSale.new do
|
391
|
+
@rep = {foo: 'bar'}
|
392
|
+
utilities
|
393
|
+
end
|
394
|
+
@utilities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
395
|
+
expect(@utilities_content).to include('Utility Description')
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe 'improvements' do
|
401
|
+
context 'with keys' do
|
402
|
+
before :each do
|
403
|
+
@pdf = ClosedSale.new do
|
404
|
+
@rep = Sampler.get_comp2
|
405
|
+
improvements
|
406
|
+
end
|
407
|
+
@improvements_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'renders static content' do
|
411
|
+
expect(@improvements_content).to include('Unit')
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'renders dynamic content from keys' do
|
415
|
+
expect(@improvements_content).to include('Shop')
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
context 'without keys' do
|
420
|
+
it 'renders static content' do
|
421
|
+
@pdf = ClosedSale.new do
|
422
|
+
@rep = {foo: 'bar'}
|
423
|
+
improvements
|
424
|
+
end
|
425
|
+
|
426
|
+
@improvements_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
427
|
+
expect(@improvements_content).to include('Unit')
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
describe 'water_rights' do
|
433
|
+
context 'with keys' do
|
434
|
+
before :each do
|
435
|
+
@pdf = ClosedSale.new do
|
436
|
+
@rep = Sampler.get_comp2
|
437
|
+
water_rights
|
438
|
+
end
|
439
|
+
@water_rights_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'renders static content' do
|
443
|
+
expect(@water_rights_content).to include('Source')
|
444
|
+
end
|
445
|
+
|
446
|
+
it 'renders dynamic content from keys' do
|
447
|
+
expect(@water_rights_content).to include('Surface')
|
448
|
+
end
|
449
|
+
|
450
|
+
end
|
451
|
+
|
452
|
+
context 'without keys' do
|
453
|
+
it 'renders static content' do
|
454
|
+
@pdf = ClosedSale.new do
|
455
|
+
@rep = {foo: 'bar'}
|
456
|
+
water_rights
|
457
|
+
end
|
458
|
+
@water_rights_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
459
|
+
expect(@water_rights_content).to include('Source')
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
describe 'water_distribution' do
|
465
|
+
context 'with keys' do
|
466
|
+
before :each do
|
467
|
+
@pdf = ClosedSale.new do
|
468
|
+
@rep = Sampler.get_comp2
|
469
|
+
water_distribution
|
470
|
+
end
|
471
|
+
page1 = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
472
|
+
page2 = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
|
473
|
+
@water_distribution_content = page1 + page2
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'renders static content' do
|
477
|
+
expect(@water_distribution_content).to include('Type')
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'renders dynamic content from keys' do
|
481
|
+
expect(@water_distribution_content).to include('Pump')
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
|
486
|
+
context 'without keys' do
|
487
|
+
it 'renders static content' do
|
488
|
+
@pdf = ClosedSale.new do
|
489
|
+
@rep = {foo: 'bar'}
|
490
|
+
water_distribution
|
491
|
+
end
|
492
|
+
@water_distribution_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
493
|
+
expect(@water_distribution_content).to include('Type')
|
494
|
+
end
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
describe 'crop_yield' do
|
499
|
+
context 'with keys' do
|
500
|
+
before :each do
|
501
|
+
@pdf = ClosedSale.new do
|
502
|
+
@rep = Sampler.get_comp2
|
503
|
+
crop_yield
|
504
|
+
end
|
505
|
+
@crop_yield_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
506
|
+
end
|
507
|
+
|
508
|
+
it 'renders static content' do
|
509
|
+
expect(@crop_yield_content).to include('Commodity')
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'renders dynamic content from keys' do
|
513
|
+
expect(@crop_yield_content).to include('2010')
|
514
|
+
end
|
515
|
+
|
516
|
+
end
|
517
|
+
|
518
|
+
context 'without keys' do
|
519
|
+
it 'renders static content' do
|
520
|
+
@pdf = ClosedSale.new do
|
521
|
+
@rep = {foo: 'bar'}
|
522
|
+
crop_yield
|
523
|
+
end
|
524
|
+
@crop_yield_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
525
|
+
expect(@crop_yield_content).to include('Crop')
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
describe 'estimated productivity' do
|
531
|
+
context 'with keys' do
|
532
|
+
it 'renders static content' do
|
533
|
+
@pdf = ClosedSale.new do
|
534
|
+
@rep = Sampler.get_comp2
|
535
|
+
estimated_productivity
|
536
|
+
end
|
537
|
+
@productivity_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
538
|
+
expect(@productivity_content).to include('Commodity')
|
539
|
+
end
|
540
|
+
|
541
|
+
it 'renders dynamic content from keys' do
|
542
|
+
@pdf = ClosedSale.new do
|
543
|
+
@rep = Sampler.get_comp2
|
544
|
+
estimated_productivity
|
545
|
+
end
|
546
|
+
@productivity_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
547
|
+
expect(@productivity_content).to include('Corn')
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
context 'without keys' do
|
552
|
+
it 'renders static content' do
|
553
|
+
@pdf = ClosedSale.new do
|
554
|
+
@rep = {foo: 'bar'}
|
555
|
+
estimated_productivity
|
556
|
+
end
|
557
|
+
@productivity_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
558
|
+
expect(@productivity_content).to include('Commodity')
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
describe 'perm_plantings' do
|
564
|
+
context 'with keys' do
|
565
|
+
before :each do
|
566
|
+
@pdf = ClosedSale.new do
|
567
|
+
@rep = Sampler.get_comp2
|
568
|
+
perm_plantings
|
569
|
+
end
|
570
|
+
@perm_plantings_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
571
|
+
end
|
572
|
+
|
573
|
+
it 'renders static content' do
|
574
|
+
expect(@perm_plantings_content).to include('Variety')
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'renders dynamic content from keys' do
|
578
|
+
expect(@perm_plantings_content).to include('Apples')
|
579
|
+
end
|
580
|
+
|
581
|
+
end
|
582
|
+
|
583
|
+
context 'without keys' do
|
584
|
+
it 'renders static content' do
|
585
|
+
@pdf = ClosedSale.new do
|
586
|
+
@rep = {foo: 'bar'}
|
587
|
+
perm_plantings
|
588
|
+
end
|
589
|
+
@perm_plantings_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
590
|
+
expect(@perm_plantings_content).to include('Variety')
|
591
|
+
end
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
describe 'externalities' do
|
596
|
+
context 'with keys' do
|
597
|
+
before :each do
|
598
|
+
@pdf = ClosedSale.new do
|
599
|
+
@rep = Sampler.get_comp2
|
600
|
+
externalities
|
601
|
+
end
|
602
|
+
@externalities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'renders static content' do
|
606
|
+
expect(@externalities_content).to include('Are')
|
607
|
+
end
|
608
|
+
|
609
|
+
it 'renders dynamic content from keys' do
|
610
|
+
expect(@externalities_content).to include('Triple Blade')
|
611
|
+
end
|
612
|
+
|
613
|
+
end
|
614
|
+
|
615
|
+
context 'without keys' do
|
616
|
+
it 'renders static content' do
|
617
|
+
@pdf = ClosedSale.new do
|
618
|
+
@rep = {foo: 'bar'}
|
619
|
+
externalities
|
620
|
+
end
|
621
|
+
@externalities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
|
622
|
+
expect(@externalities_content).to include('waste')
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|