Class: EvalReport

Inherits:
Prawn::Document
  • Object
show all
Includes:
ReportUtils
Defined in:
lib/eval_report.rb

Instance Method Summary collapse

Methods included from ReportUtils

average_land_val, conditional_externs_array, #datemaker, #flip_improvements_array, maximum_land_val, median_land_val, minimum_land_val, #moneymaker, #no_nil_array, #no_nil_number, #no_nil_string, parallel_text, static_strings

Constructor Details

#initializeEvalReport

Returns a new instance of EvalReport.



9
10
11
# File 'lib/eval_report.rb', line 9

def initialize()
	super()
end

Instance Method Details

#additional_docsObject



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'lib/eval_report.rb', line 968

def additional_docs
	pdf_doc_proc = Proc.new do |doc_key, title|
		if @docs[doc_key] && @docs[doc_key].any?
			start_new_page(template: @docs[doc_key][0])
			header(title)
		end
	end

	img_doc_proc = Proc.new do |doc_key, title|
		if @docs[doc_key] && @docs[doc_key].any?
			start_new_page
			header(title)
			move_down 25
			image "#{@docs[doc_key][0]}", width: 500, position: :center
		end
	end

	pdf_doc_proc.call(:engagementletter, "ENGAGEMENT LETTER")
	pdf_doc_proc.call(:legaldescription, "LEGAL DESCRIPTION")
	pdf_doc_proc.call(:warrantydeed, "WARRANTY DEED/TRANSFER DEED")
	pdf_doc_proc.call(:titleinsurancepolicy, "TITLE INSURANCE POLICY")
	pdf_doc_proc.call(:lease, "LEASE")
	pdf_doc_proc.call(:purchaseandsaleagreement, "PURCHASE AND SALE AGREEMENT")
	img_doc_proc.call(:fsamap, "FSA MAP")
	img_doc_proc.call(:fsa156, "FSA 156")
	pdf_doc_proc.call(:addendum, "ADDENDUM")
	pdf_doc_proc.call(:crpcontracts, "CRP CONTRACTS")
	img_doc_proc.call(:floodmap, "FLOOD MAP")
	img_doc_proc.call(:platmap, "PLAT MAP")
	img_doc_proc.call(:surveymap, "SURVEY MAP")
	img_doc_proc.call(:othermap, "OTHER MAP")
	pdf_doc_proc.call(:buildingschematics, "BUILDING SCHEMATICS")
	pdf_doc_proc.call(:irrigationschematics, "IRRIGATION SCHEMATICS")
	pdf_doc_proc.call(:irrigationequipment, "IRRIGATION/PUMPING EQUIPMENT INVENTORY")
	pdf_doc_proc.call(:waterrights, "WATER RIGHTS")
	pdf_doc_proc.call(:cropcontracts, "CROP CONTRACTS")
	pdf_doc_proc.call(:cropinsurancehistory, "CROP INSURANCE HISTORY")
	pdf_doc_proc.call(:timbercruise, "TIMBER CRUISE")
	pdf_doc_proc.call(:notes, "NOTES")
end

#ag_sales_mapObject



850
851
852
853
854
855
856
857
858
859
860
# File 'lib/eval_report.rb', line 850

def ag_sales_map
	header("SALES LOCATION MAP")
	move_down 50
	if @docs[:agsalesmap] && @docs[:agsalesmap].any?
		image "#{@docs[:agsalesmap][0]}", width: 500, position: :center
	else
		text 'No Image'
	end

	start_new_page
end

#assumptions_and_conditionsObject



956
957
958
959
960
961
962
963
964
965
966
# File 'lib/eval_report.rb', line 956

def assumptions_and_conditions
	header("ASSUMPTIONS AND LIMITING CONDITIONS")
	move_down 25
	text "ASSUMPTIONS AND LIMITING CONDITIONS", size: 14, style: :bold
	move_down 20
	text "#{@text_blocks[:assumptions_conditions]}", style: :bold
	move_down 20
	text "Evaluators Associated with this Evaluation Report are identified as follows:"
	move_down 10
	text "#{@sub[:validentification]}"
end

#cover_pageObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/eval_report.rb', line 57

def cover_page
	bounding_box([220, 700], width: 320, height: 700) do
		text 'EVALUATION OF REAL PROPERTY', size: 14
		move_down 5
		text "#{@sub[:primary_ag_use]}"

		if @sub[:property_inclusions] && @sub[:property_inclusions].any?
			move_down 3
			text "#{@sub[:property_inclusions].join(', ')}"
		end

		move_down 10

		text "#{@sub[:property_name]}"
		move_down 3
		text "#{@sub[:county_state]}".slice(0..-3)
		move_down 3
		text "#{@sub[:property_address_number]} " << "#{@sub[:street_or_road_name]}"
		move_down 3
		add_string = ""
		add_string << "#{@sub[:city]}, "  

		if @sub[:county_state]
			add_string << "#{@sub[:county_state].slice(-2..-1)} "
		end

		add_string << "#{@sub[:zip_code]}"
		text add_string
		move_down 25
		
		text 'AGRICULTURAL REAL ESTATE EVALUATION', size: 14
		move_down 10
		text 'As of ' << "#{datemaker(@sub[:effvaluedateasis])}"
		move_down 3
		text 'Report Date: ' << "#{datemaker(@sub[:valreportdate])}"
		move_down 15

		text 'Prepared For:'
		text "#{@sub[:clientid]}"
		text "#{@sub[:clientaddress]}"
		text "#{@sub[:clientcontact]}"
		text "#{@sub[:clientrefnum]}"
		move_down 10
		text 'Prepared By:'
		text "#{@sub[:record_created_by]}"
		# "#{@sub[:tenant_name]}" # not found currently
		# "#{@sub[:tenant_contact]}" # not found currently
	end

	stroke_bounds
	start_new_page
end

#crop_yieldObject



1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
# File 'lib/eval_report.rb', line 1262

def crop_yield
	crops = @sub[:crops]

	crop_data = [
		[{content: "Crop Yield Summary", colspan: 7}],
		["Crop Year", "Commodity Identified", "Unit of Measure", "Average Yield", " ", " ", ", "]
	]

	if crops # node could be nil
		crops.each do |c|
			if c # array could be empty
				crop_data.push(
					["#{c[:year]}", "#{c[:commodity]}", "#{c[:unit]}", "#{c[:avgyield]}"]
				)
			end
		end
	end

	table(crop_data) do
		column(0).width = 135
		columns(1..6).width = 67.5
		columns(0..6).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
end

#discussion_of_salesObject



783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# File 'lib/eval_report.rb', line 783

def discussion_of_sales
	if @comps && @comps.any? # just skip the table if there aren't any comps
		header("COMPARABLE SALES COMMENTS")
		font_size 9

		table(flip_discussions(@comps.first(5))) do
			cells.padding = [1, 2.5]
			columns(0..4).width = 108
			row(0).style(align: :center, background_color: 'd7d7d7')
			cells.style(border_width: 0)
			columns(0..5).style(border_right_width: 0.5)
		end

		if @comps.length > 5
			start_new_page 
			header("COMPARABLE SALES COMMENTS")
			table(flip_discussions(@comps[5..9])) do
				cells.padding = [1, 2.5]
				columns(0..4).width = 108
				row(0).style(align: :center, background_color: 'd7d7d7')
				cells.style(border_width: 0)
				columns(0..5).style(border_right_width: 0.5)
			end
		end
	end
	start_new_page
	font_size 11
end

#externalitiesObject



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
# File 'lib/eval_report.rb', line 1319

def externalities
	extern_data = ReportUtils.conditional_externs_array(@sub) # instance method to populate dynamic array
	table(extern_data) do
		columns(0..3).width = 135
		columns([1, 3]).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', font_size: 8, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
	end
end

#finish_tocObject



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/eval_report.rb', line 221

def finish_toc
	go_to_page(5)
	move_down 30
	@toc_hash.each do |k, v|
		float do
			indent(500) do
				text "#{v}"
			end
		end

		text "#{k}"
		stroke_horizontal_rule
		move_down 5
	end
end

#flip_comp_array(comps_to_flip) ⇒ Object

necessary to produce 2D array of comps side by side



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/eval_report.rb', line 1035

def flip_comp_array(comps_to_flip) # necessary to produce 2D array of comps side by side
	props = [@sub, comps_to_flip].compact.flatten
	@comp_increment ||= 0
	final_a = [
		[{content: 'Valuation Analysis', colspan: 7}], # [0]
		['Characteristic', 'Subject'], # [1]
		['Record No.'], ['Tax Parcel #(s)'], ['Address'], ['City'], ['State'], ['Zip Code'], ['Sale Date'], ['Sale Price'], # [2] -> [9]
		['Conditions of Sale'], ['Adjusted Sale Price'], ['Property Rights Conveyed'], ['Unit of Comparison'], # [10 -> 13]
		['Price/Unit'], ['Total Acres'], ['Primary Land Use'], ['No. Primary Units - Acres'], ['$/Unit - Primary Land'], # [14 -> 18]
		['Secondary Land Use'], ['No. Secondary Units - Acres'], ['$/Unit - Secondary Land'], # [19 -> 21]
		['$/Unit Allocated to Improvements'], ['Physical Access'], ['Legal Access'], # [22 -> 24] 
		['Topography'], ['Rainfal'], ['Primary Crop'], ['Yield'], ['Cap Rate'], [''], # [25 -> 30]
		['% Primary Land'], [''], ['Deed Instrument No.'] # [31 -> 33]
	]

	props.each do |p|
		final_a[2].push(p[:sequence]) # record number

		taxes = p[:taxes]
		if taxes && taxes.any?
				t_s = taxes.inject("") {|memo_s, t| memo_s << "#{t[:tax_parcel_no]}, "; memo_s }
		else
				t_s = ""
		end

		final_a[1].push("Sale #{@comp_increment}") unless @comp_increment == 0
		@comp_increment += 1

		final_a[3].push(t_s) # tax parcels
		final_a[4].push("#{p[:property_address_number]} " << "#{p[:street_or_road_name]}") # address
		final_a[5].push("#{p[:city]}") # city
		final_a[6].push("#{p[:county_state]}".slice(-2..-1)) # state
		final_a[7].push("#{p[:zip_code]}") # zip
		final_a[8].push(datemaker(p[:sale_date])) # sale date
		final_a[9].push(moneymaker(p[:sale_price],false)) # sale price
		final_a[10].push(moneymaker(p[:sale_adjustment],false)) # conditions of sale
		final_a[11].push(moneymaker(p[:cesaleprice],false)) # adjusted sale price
		final_a[12].push("#{p[:property_rights]}") # property rights conveyed
		final_a[13].push("#{p[:unit]}") # unit of comparison
		final_a[14].push(moneymaker(p[:cesaleunitprice],false)) # price/unit
		final_a[15].push("#{p[:num_of_units]}") # total acres
		final_a[16].push("#{p[:primary_ag_use]}") # primary land use

		if p[:landclassifications] && p[:landclassifications].any?
			units_primary = p[:landclassifications][0][:numacres]

			per_acre_string = moneymaker(p[:landclassifications][0][:priceperacre], false)

			if p[:landclassifications][1]
				secondary_per_acre = moneymaker(p[:landclassifications][1][:priceperacre], false)
				units_secondary = p[:landclassifications][1][:numacres]
			else
				units_secondary = 0
				secondary_per_acre = 0
			end
		else
			units_primary = 0
			units_secondary = 0
		end

		percent_primary = p[:num_of_units] ? ((units_primary * 100) / p[:num_of_units]) : 0
		
		final_a[17].push(units_primary) # no. units
		final_a[18].push(per_acre_string) # $/unit - primary
		final_a[19].push(p[:secondary_ag_use]) # secondary land use
		final_a[20].push(units_secondary) # no. units - acres
		final_a[21].push(secondary_per_acre) # $/unit - secondary


		expenses_per_unit = p[:num_of_units] ? (Money.new(no_nil_number(p[:total_expenses]) * 100, 'USD') / p[:num_of_units]).format(no_cents: true) : 0

		final_a[22].push(expenses_per_unit) # $/unit allocated to improvements
		final_a[23].push("#{p[:has_physical_access]} " << "#{p[:physical_access]}") # physical access
		final_a[24].push("#{p[:has_legal_access]} " << "#{p[:legal_access]}") # legal access
		final_a[25].push(p[:topography]) # topography
		final_a[26].push(p[:avg_precipitation]) # rainfall

		if p[:estimatedproductivity] && p[:estimatedproductivity].any?
			primary_commodity = "#{p[:estimatedproductivity][0][:commodity]}"
			commodity_num_primary = no_nil_number(p[:estimatedproductivity][0][:estmtdyield])

		else
			commodity_num_primary = 0
			primary_commodity = "None"
		end

		final_a[27].push(primary_commodity) # primary crop
		final_a[28].push(commodity_num_primary) # yield
		final_a[29].push("#{p[:overall_capitalization_rate]}%") # cap rate
		# [30] is a blank line
		final_a[31].push("#{percent_primary}%") # % primary land
		# [32] is a blank line
		final_a[33].push(p[:public_rec_ref_number]) # deed instrument no.
	end

	return final_a

end

#flip_discussions(comps_to_flip) ⇒ Object



812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
# File 'lib/eval_report.rb', line 812

def flip_discussions(comps_to_flip)
	@discussion_increment ||= 1
	discussion_data = [
			[]
		]
		sale_discussions = []

		comps_to_flip.each do |c|
			c_string = " "
			c_string << "#{c[:directions_or_ownership_comments]}\n\n" unless !c[:directions_or_ownership_comments] || "#{c[:directions_or_ownership_comments]}".empty?
			c_string << "#{c[:allowed_uses_and_limitations]}\n\n" unless !c[:allowed_uses_and_limitations] || "#{c[:allowed_uses_and_limitations]}".empty?
			c_string << "#{c[:development_potential]}\n\n" unless !c[:development_potential] || "#{c[:development_potential]}".empty?	
			c_string << "#{c[:comments_on_floodways]}\n\n" unless !c[:comments_on_floodways] || "#{c[:comments_on_floodways]}".empty? 
			c_string << "#{c[:sale_adjustment_comments]}\n\n" unless !c[:sale_adjustment_comments] || "#{c[:sale_adjustment_comments]}".empty?
			c_string << "#{c[:general_comments]}\n\n"  unless !c[:general_comments] || "#{c[:general_comments]}".empty?
			c_string << "#{c[:atmarket_comments]}\n\n" unless !c[:atmarket_comments] || "#{c[:atmarket_comments]}".empty? 
			c_string << "#{c[:listing_comments]}\n\n" unless !c[:listing_comments] || "#{c[:listing_comments]}".empty?
			c_string << "#{c[:lease_comments]}\n\n" unless !c[:lease_comments]  || "#{c[:lease_comments]}".empty?
			c_string << "#{c[:change_of_use]}\n\n" unless !c[:change_of_use] || "#{c[:change_of_use]}".empty?
			c_string << "#{c[:water_rights_comment]}\n\n" unless !c[:water_rights_comment] || "#{c[:water_rights_comment]}".empty?
			c_string << "#{c[:water_distribution_comment]}\n\n" unless !c[:water_distribution_comment] || "#{c[:water_distribution_comment]}".empty?
			c_string << "#{c[:accessibility]}\n\n" unless !c[:accessibility] || "#{c[:accessibility]}".empty?
			c_string << "#{c[:easements_description]}\n\n" unless !c[:easements_description] || "#{c[:easements_description]}".empty?
			c_string << "#{c[:elevation]}\n\n" unless !c[:elevation] || "#{c[:elevation]}".empty? 
			c_string << "#{c[:property_improvement_comments]}\n\n" unless !c[:property_improvement_comments] || "#{c[:property_improvement_comments]}".empty? 
			c_string << "#{c[:income_comments]}" unless !c[:income_comments] || "#{c[:income_comments]}".empty?

			# build on sub-array
			discussion_data[0] << "Sale #{@discussion_increment}"
			@discussion_increment += 1
			sale_discussions << c_string
		end
		# push subarray to main table array
		discussion_data << sale_discussions

		return discussion_data
end

#header(page_title) ⇒ Object



1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/eval_report.rb', line 1023

def header(page_title)
	text "#{page_title}  " << "#{page_count - 1}", align: :right

	# build up the hash for table of contents
	@toc_hash ||= {}
	if @toc_hash[page_title] == nil
		@toc_hash[page_title] = page_count - 1
	end

	stroke_horizontal_rule
end

#image_cap(title) ⇒ Object



1330
1331
1332
1333
1334
1335
1336
1337
1338
# File 'lib/eval_report.rb', line 1330

def image_cap(title)
	float do
		fill_color '24478F'
		fill_rectangle [120, cursor], 300, 20
		fill_color '000000'
	end
	move_down 4
	text "#{title}", align: :center, color: 'ffffff'
end

#improvementsObject



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
# File 'lib/eval_report.rb', line 1190

def improvements
	improvements_array = @sub[:improvements]			
	
	sorted_array = flip_improvements_array(improvements_array)

	table(sorted_array) do
		columns(0..7).width = 67.5
		columns(1..7).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end 
	# no new page
end

#introductionObject



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/eval_report.rb', line 237

def introduction
	header("INTRODUCTION")
	move_down 25
	text "INTRODUCTION", size: 14, style: :bold
	move_down 10
	text "SCOPE OF WORK", size: 14, style: :bold
	text @text_blocks[:scope_of_work1]
	move_down 10
	
	if @sub[:research] && @sub[:research].any?
		@sub[:research].each do |r|
			float do # building a checkbox because there is no support for them in base 14 fonts
				float do
					rectangle [0, cursor], 12, 12
					stroke
				end
				text 'X', size: 15 
			end

			indent(50) do
				text r
				move_down 10
			end
		end
	end

	move_down 5
	text @text_blocks[:scope_of_work3]
	start_new_page
end

#letter_of_transmittalObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/eval_report.rb', line 110

def letter_of_transmittal
	header("LETTER OF TRANSMITTAL")
	move_down 10
	text "#{datemaker(@sub[:valreportdate])}"
	text "#{@sub[:clientid]}"
	text "#{@sub[:clientaddress]}"
	text "#{@sub[:clientcontact]}"

	move_down 25
	float do
		text "Re:"
	end

	indent(30) do
		taxes = @sub[:taxes]
		if taxes && taxes.any?
				t_s = taxes.inject("") {|memo_s, t| memo_s << "#{t[:tax_parcel_no]}, "; memo_s }
		else
				t_s = " "
		end

		
		parallel_text("Evaluation of Real Property", " ", 150)
		parallel_text("Property Type:", "#{@sub[:primary_ag_use]}", 150)
		parallel_text("Property Name:", "#{@sub[:property_name]}", 150)
		parallel_text("Tax Parcel ID No.:", t_s , 150)
		parallel_text("County:","#{@sub[:county_state]}".slice(0..-3), 150)
		parallel_text("Street Address:", "#{@sub[:property_address_number]}" << "#{@sub[:street_or_road_name]}", 150)
		parallel_text("City, State, Zip Code:", "#{@sub[:city]}" << "#{@sub[:county_state]}".split('').last(2).join(''), 150)
		parallel_text("Client Assignment Ref. No.:", "#{@sub[:clientrefnum]}", 150)
		parallel_text("Valuator's Internal File No.:", "#{@sub[:_id]}", 150)
	end

	move_cursor_to 450
	text "Dear " << "#{@sub[:clientid]},"
	move_down 10
	text @text_blocks[:transmittal]
	start_new_page
end

#office_logoObject



52
53
54
55
# File 'lib/eval_report.rb', line 52

def 
	move_down 550
	image "#{@logo}", width: 200
end

#perm_plantingsObject



1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
# File 'lib/eval_report.rb', line 1291

def perm_plantings
	planting_data = [
		[{content: "Permanent Plantings", colspan: 8}],
		["Planting", "Variety", "Ac. Type", "No. of Acres", "Average Age", "Plants/Acre", "Unit Description", "Average Yield"]
	]

	plantings = @sub[:plantings]

	if plantings # node could be nil
		plantings.each do |p|
			if p # array could be empty
				planting_data.push(
					["#{p[:planting]}", "#{p[:variety]}", "#{p[:acres]}", "#{p[:numacres]}", "#{p[:avgage]}", "#{p[:plantsacre]}", "#{p[:unitdescr1]}", "#{p[:avgproduction]}"]
				)
			end
		end
	end

	table(planting_data) do
		columns(0..7).width = 67.5
		columns(0..7).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
end

#prepare_comps_for_calcObject



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
# File 'lib/eval_report.rb', line 1009

def prepare_comps_for_calc
	@comps.each do |p|
		if p[:landclassifications] && p[:landclassifications].any?
			primary_per_acre = p[:landclassifications][0][:priceperacre] ? p[:landclassifications][0][:priceperacre][:cents] / 100 : nil
			@recon_primary_per_acre << primary_per_acre.to_f unless primary_per_acre == nil

			if p[:landclassifications][1]
				secondary_per_acre = p[:landclassifications][1][:priceperacre] ? p[:landclassifications][1][:priceperacre][:cents] / 100 : nil
				@recon_secondary_per_acre << secondary_per_acre.to_f unless secondary_per_acre == nil
			end
		end
	end
end

#property_comparisonObject



746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'lib/eval_report.rb', line 746

def property_comparison
	header("DIRECT COMPARISON ANALYSIS")
	move_down 10
	font_size 7

	table(flip_comp_array(@comps.first(5))) do
		column(0).width = 90
		columns(1..6).width = 75
		cells.padding = [1, 2.5]
		columns(1..6).style(align: :center)
		row(0).style(border_right_width: 0, border_top_width: 0, border_left_width: 0, border_bottom_width: 0)
		row(0).style(font_style: :bold, size: 11)
	end

	if @comps.length > 5
		start_new_page
		font_size 11
		header("DIRECT COMPARISON ANALYSIS")
		move_down 10
		font_size 7

		second_page_comps = flip_comp_array(@comps[5..9])
		second_page_comps[1].delete_at(-1) # remove the extra sale header on the second page of sales
		table(second_page_comps) do
			column(0).width = 90
			columns(1..6).width = 75
			cells.padding = [1, 2.5]
			columns(1..6).style(align: :center)
			row(0).style(border_right_width: 0, border_top_width: 0, border_left_width: 0, border_bottom_width: 0)
			row(0).style(font_style: :bold, size: 11)
		end
	end

	start_new_page
	font_size 11
end

#property_descriptionObject



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'lib/eval_report.rb', line 373

def property_description
	header("PROPERTY DESCRIPTION")
	move_down 10
	text "PROPERTY DESCRIPTION, SURROUNDING LAND USES, REGIONAL ECONOMIC AND DEMOGRAPHIC OVERVIEW", size: 14, style: :bold
	font_size 6
	bounding_box([0, 645], height: 300, width: 340) do
		if @sub[:landclassifications] && @sub[:landclassifications].any?
			@number_acres = @sub[:landclassifications].inject(0) {|memo, l| memo += no_nil_number(l[:numacres]); memo }
		else
			@number_acres = 0
		end

		general_data = [
			[{content: "General Information", colspan:2}],
			["Effective Date of Analysis:", "#{@sub[:effvaluedateasis]}"],
			["Property Rights Being Analyzed:", "#{@sub[:property_rights]}"],
			["Total No. Acres:", @number_acres]
		]

		table(general_data) do
			columns(0..1).width = 170
			cells.style(border_width: 0)
			cells.padding = [1, 2.5]
			column(0).style(font_style: :bold, align: :right)
			row(0).style(align: :center, border_bottom_width: 0.5)
		end

		# construction of combo strings
		street_address = "#{@sub[:property_address_number]} " << "#{@sub[:street_or_road_name]}"
		lat_long_string = ""
		lat_long_string << "#{@sub[:position][0]}/#{@sub[:position][1]}" unless @sub[:position] == nil
		meridian_town_range = "#{@sub[:meridian]}, " << "#{@sub[:township]} " << "#{@sub[:range]}"
		
		taxes = @sub[:taxes]
		if taxes
			parcel_nos = taxes.inject("") {|memo, t| memo << "#{t[:tax_parcel_no]}; "; memo}
		else
			parcel_nos = ""
		end

		re_tax_string = "#{@sub[:total_RET]}  "
		if @number_acres == 0
			re_tax_string << "/  0"
		else
			re_tax_string << "/  #{@sub[:total_RET].to_f / @number_acres}"
		end

		if @sub[:county_state]
			state_string = "#{@sub[:county_state].slice(-2..-1)}"
		else
			state_string = ""
		end

		identification_data = [
			[{content: "Property Identification", colspan: 2}],
			["Property Owner:", "#{@sub[:curr_owner]}"],
			["Property Name:", "#{@sub[:property_name]}"],
			["Street Address:", street_address],
			["City:", "#{@sub[:city]}"],
			["State:", state_string],
			["Zip Code:", "#{@sub[:zip_code]}"],
			["Latitude/Longitude:", lat_long_string],
			["Meridian/Township/Range:", meridian_town_range],
			["Brief Legal:", "#{@sub[:legal_description]}"],
			["Tax Parcel ID(s):", parcel_nos],
			["RE Taxes/ $/Acre:", re_tax_string],
			["Assessed Value of Land:", "#{@sub[:total_assess_value]}"],
			["Current Real Estate Taxes", "#{@sub[:total_RET]}"],
			["Total Number of Acres:", @number_acres],
			["Land Use Zone and Allowed Uses:", "#{@sub[:land_use_zone]}, #{@sub[:allowed_uses_and_limitations]}"],
			["Does property conform to zoning?:", "#{@sub[:conf_type]}"],
			["Is Property located in Flood Zone/Wetland?:", "#{@sub[:flood_zone]} #{@sub[:wetlands]}"],
			["Is Property currently listed, under contract? If property has sold in prior 3 years see Transaction History table below.", "#{@sub[:under_purchase_agr]}, #{@sub[:listed_for_sale]}"],
			["Does Property have Legal Access? How?:", "#{@sub[:has_legal_access]} / #{@sub[:legal_access]}"],
			["Does the property have Physical Access? How?:", "#{@sub[:has_physical_access]} / #{@sub[:physical_access]}"],
			["Easements, ROW or Encroachments:", "#{@sub[:easements_description]}"]
		]

		table(identification_data) do
			columns(0..1).width = 170
			cells.style(border_width: 0)
			cells.padding = [1, 2.5]
			row(0).style(align: :center, font_style: :bold, border_bottom_width: 0.5)
			column(0).style(align: :center)
		end

		stroke_bounds
	end

	bounding_box([340, 645], height: 300, width: 200) do
		neighborhood_data = [
			[{content: "Neighborhood Information", colspan: 2}],
			["Land Use North:", "#{@sub[:north_land]}"],
			["Land Use South:", "#{@sub[:south_land]}"],
			["Land Use East:", "#{@sub[:east_land]}"],
			["Land Use West:", "#{@sub[:west_land]}"],
			[{content: "Comments - Distance to Services, Farm to Market, etc.:", colspan: 2}],
			[{content: "#{@sub[:SWOT_analysis1]}", colspan: 2}]
		]

		table(neighborhood_data) do
			cells.style(border_width: 0)
			cells.padding = [1, 2.5]
			column(0).style(align: :right)
			row(0).style(align: :center, font_style: :bold, border_bottom_width: 0.5)
			column(0).width = 80
			column(1).width = 120
		end

		stroke_horizontal_rule
		text "Economics and Demographics", align: :center, style: :bold
		stroke_horizontal_rule
		move_down 3
		text "Pertinent Local Economic Factors including a description of current supply and 
		demand of similar property types and commodities produced. Included influences on value."
		stroke_horizontal_rule
		move_down 3
		text "#{@sub[:SWOT_analysis2]}"

		stroke_bounds
	end

	# Property Description Table Header
	move_down 4
	text 'Property Description', align: :center, style: :bold


	# bounding box for left table under property description section
	bounding_box([0, 330], height: 230, width: 270) do
		inclusions = @sub[:inclusions]
		if inclusions
			incl_string = inclusions.join(", ")
		else
			incl_string = ""
		end

		# getting primary and secondary land classes by index
		if @sub[:landclassifications] && @sub[:landclassifications].any?
			num_primary = no_nil_number(@sub[:landclassifications][0][:numacres])

			if @sub[:landclassifications][1]
				num_secondary = no_nil_number(@sub[:landclassifications][1][:numacres])
				secondary_land_type = @sub[:landclassifications][1][:landclass]
			else
				num_secondary = 0
			end
		else
			num_primary = 0
			num_secondary = 0
		end

		# getting primary and secondary commodities by index
		if @sub[:estimatedproductivity] && @sub[:estimatedproductivity].any?
			primary_commodity = "#{@sub[:estimatedproductivity][0][:commodity]}"
			commodity_num_primary = no_nil_number(@sub[:estimatedproductivity][0][:estmtdyield])

			if @sub[:estimatedproductivity][1]
				secondary_commodity = "#{@sub[:estimatedproductivity][1][:commodity]}"
				commodity_num_secondary = no_nil_number(@sub[:estimatedproductivity][1][:estmtdyield])
			else
				commodity_num_secondary = 0
				secondarycommodity = "None"
			end

		else
			commodity_num_primary = 0
			commodity_num_secondary = 0
			secondary_commodity = "None"
			primary_commodity = "None"
		end

		# conditional strings
		is_encumbered = @sub[:occupancy] == "leased" || @sub[:occupancy] == "partially leased" ? "Yes" : "No"
		end_of_lease = @sub[:lease_data] && @sub[:lease_data].any? ? datemaker(@sub[:lease_data][0][:endLeaseDate]) : "NA"

		if @sub[:inclusions] 
			has_improvs = (@sub[:inclusions] & ["Improved with non-Ag Use Improvements", 
																					"Improved with Ag Use Improvements", 
																					"Improved with residence"]).present?
			improvs_string = has_improvs ? "See Improvements Table" : "No"
		else
			improvs_string = "No"
		end

		# calculated strings
		income = Money.new(no_nil_number(@sub[:eff_gross_income]) * 100, 'USD')
		expense = Money.new(no_nil_number(@sub[:total_expenses]) * 100, 'USD')
		noi = income - expense
		noi_string = noi.format(no_cents: :true)
		expense_ratio = "#{((expense / income) * 100).round(2)}" + "%"

		description_data2 = [
			["Effective Unit Size/Acres:", "#{@sub[:num_of_units]}"],
			["Current Land Use", "See General Comments"],
			["Historic Land Use:", "See General Comments"],
			["Intended Future use by Borrower:", "#{@sub[:change_of_use]}"],
			["Occupancy:", "#{@sub[:occupancy]}"],
			["What does this property include?:", incl_string],
			["Primary Agricultural Land Use:", "#{@sub[:primary_ag_use]}"],
			["Primary Agricultural Land Use Acres:", num_primary],
			["Primary Commodity:", primary_commodity],
			["Primary Ag Commodity Est. Productivity Yield:", commodity_num_primary],
			["Secondary Agricultural Land Class:", secondary_land_type],
			["Secondary Agricultural Land Use Acres:", num_secondary],
			["Secondary Commodity:", secondary_commodity],
			["Secondary Ag Commodity Est. Productivity Yield:", commodity_num_secondary],
			["Is subject encumbered by a current lease?:", is_encumbered],
			["Lease Structure:", "#{@sub[:type_of_lease]}"],
			["Lease Term:", end_of_lease],
			["NOI Projected Income from Rent:", noi_string],
			["Expense Ratio:", expense_ratio],
			["Does the subject have Building Improvements?:", improvs_string]
		]
		
		table(description_data2) do
			cells.style(border_width: 0)
			cells.padding = [1, 2.5]
			column(0).style(align: :right)
			column(0..1).width = 135
		end

		stroke_bounds
	end

	# bounding box for right table under property description section
	bounding_box([270, 330], height: 230, width: 270) do

		if @sub[:perm_plantings] && @sub[:perm_plantings].any?
			has_perm_plants = "Yes"
		else
			has_perm_plants = "No"
		end

		if @sub[:crops] && @sub[:crops].any?
			has_crops = "Yes"
		else
			has_crops = "No"
		end

		description_data = [
			["Infrastructure-Farming Practice:", "#{@sub[:farming_practices]}"],
			["Predominant Soils Types:", "See Comments Below"],
			["Dominant Soils Capability Class:", "#{@sub[:soils]}"],
			["Corn Suitability Rating (NRCS):", "#{@sub[:CSR2]}"],
			["Average Annual Precipitation:", "#{@sub[:avg_precipitation]}"],
			["Average Growing Season:", "#{@sub[:growing_season]}"],
			["Elevation:", "#{@sub[:elevation]}"],
			["Predominant Slope:", "#{@sub[:topography]}"],
			["Does property have water rights?:", "#{@sub[:any_water_rights]}"],
			["Annual Water Cost/Irrigated Acre:", "#{moneymaker(@sub[:irrig_cost_per_acre], false)}"],
			["Does the property have a water distribution system?", "stubbed"],
			["Annual Pumping Cost/Irrigated Acre:", "#{moneymaker(@sub[:pumping_cost_per_acre], false)}"],
			["Does the property have Permanent Plantings?", has_perm_plants],
			["Is a Crop Insurance Yield Report Available?", has_crops],
			[{content: "Soils, Water, Distribution System, Permanent Planting Comments", colspan: 2}],
			[{content: "#{@sub[:soils]} #{@sub[:accessibility]} #{@sub[:mineral_rights]} #{@sub[:water_rights_comment]} #{@sub[:water_distribution_comment]}", colspan: 2}]
		]

		table(description_data) do
			cells.style(border_width: 0)
			cells.padding = [1, 2.5]
			column(0).style(align: :right)
			row(-2).style(align: :center, border_bottom_width: 0.5, border_top_width: 0.5)
			row(-1).style(align: :left)

		end

		stroke_bounds
	end
	move_down 3
	text "General Comments - Subject Property", align: :center, style: :bold
	stroke_horizontal_rule
	move_down 3

	comment_proc = Proc.new do |k|
		if k
			text "#{k}"
		end
	end

	comment_proc.call(@sub[:directions_or_ownership_comments])
	comment_proc.call(@sub[:development_potential])
	comment_proc.call(@sub[:general_comments])
	comment_proc.call(@sub[:listing_comments])
	comment_proc.call(@sub[:lease_comments])
	comment_proc.call(@sub[:foo])
	comment_proc.call(@sub[:foo])
	comment_proc.call(@sub[:income_comments])
	comment_proc.call(@sub[:problem_descr])
	comment_proc.call(@sub[:hazard_descr])
	comment_proc.call(@sub[:env_problem_descr])
	comment_proc.call(@sub[:windgen_comment])

	start_new_page
	font_size 11 # change fontsize back to default
end

#property_featuresObject

container method to create various tables



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
# File 'lib/eval_report.rb', line 670

def property_features # container method to create various tables
	move_down 3
	header("PROPERTY DESCRIPTION")
	move_down 5
	font_size 7
	stroke_bounds
	if @sub[:transactions] && @sub[:transactions].any?
		transaction_history
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	if @sub[:utilities] && @sub[:utilities].any?
		utilities
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	if @sub[:improvements] && @sub[:improvements].any?
		improvements
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	if @sub[:waterrights] && @sub[:waterrights].any?
		water_rights
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	if @sub[:waterdistributions] && @sub[:waterdistributions].any?
		water_distribution
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end
	
	if @sub[:crops] && @sub[:crops].any?
		crop_yield
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	if @sub[:plantings] && @sub[:plantings].any?
		perm_plantings
		move_down 15
		stroke_horizontal_rule
		move_down 5
	end

	externalities
	start_new_page
	font_size 11
end

#property_identificationObject



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/eval_report.rb', line 268

def property_identification
	header("PROPERTY IDENTIFICATION")
	move_down 25

	parallel_text("Effective Date of Value", "#{datemaker(@sub[:effvaluedateasis])}", 150)
	move_down 30
	parallel_text("Report Date:", "#{datemaker(@sub[:valreportdate])}", 150)
	move_down 30
	parallel_text("Estate Valued:", "#{@sub[:property_rights]}", 150)
	move_down 30
	parallel_text("Intended Use:", no_nil_array(@sub[:intendeduse]).join(", "), 150)
	move_down 30
	parallel_text("Intended User:", "#{@sub[:intendeduser]}", 150)
	move_down 30
	parallel_text("Problem being solved:","#{@sub[:appproblem]}", 150)
	move_down 30

	text "CONFORMITY AND COMPLIANCE IDENTIFICATION FOR THIS EVALUATION ANALYSIS", size: 14, style: :bold
	move_down 20
	text "#{no_nil_array(@sub[:complianceid]).join(', ')}"
	move_down 30

	text "DEFINITION OF VALUE USED IN THIS EVALUATION:", size: 14, style: :bold
	move_down 20
	text "#{no_nil_array(@sub[:valuationvalues]).join(', ')}"
	move_down 30

	text "ASSUMPTIONS:", size: 14, style: :bold
	move_down 20
	text "#{(@sub[:extrassumptions])}"
	move_down 30

	text "EXPOSURE TIME:", size: 14, style: :bold
	move_down 20
	text "#{@sub[:exptimereasoning]}"
	move_down 30

	text "MARKETING TIME:", size: 14, style: :bold
	move_down 20
	text "#{@sub[:marketingtimereasoning]}"
	move_down 30

	start_new_page
end

#regional_mapsObject



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/eval_report.rb', line 313

def regional_maps
	header("REGIONAL MAPS")
	move_down 25
	text "REGIONAL MAPS", size: 14, align: :center
	if @docs[:statemap] && @docs[:statemap].any?
		if @docs[:statemap][0]
			image_cap("STATE MAP")
			image "#{@docs[:statemap][0]}", width: 300, position: :center
			move_down 25
		else
			text 'No Image', align: :center
			move_cursor_to 350
		end

		if @docs[:countymap] && @docs[:countymap].any?
			image_cap("COUNTY MAP")
			image "#{@docs[:countymap][0]}", width: 300, position: :center
		else
			text 'No Image', align: :center
			move_cursor_to 350
		end
	else
		text 'No Image', align: :center
		move_cursor_to 350
		text 'No Image', align: :center
	end

	start_new_page
end

#subject_imagesObject



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/eval_report.rb', line 150

def subject_images
	header("SUBJECT PHOTOGRAPHS")
	move_down 10
	if @docs[:photos] && @docs[:photos].any?
		if @docs[:photos][0]
			image_cap("")
			image "#{@docs[:photos][0]}", width: 300, position: :center
			move_down 2
			text "Subject Property - Representative Image", align: :center
			move_down 25
		else
			text "No Image", align: :center
			move_cursor_to 350
		end

		if @docs[:photos][1]
			image_cap("")
			image "#{@docs[:photos][1]}", width: 300, position: :center
			move_down 2
			text "Subject Property - Representative Image", align: :center
			move_down 25
		else
			text "No Image", align: :center
			move_cursor_to 350
		end


		start_new_page
		header("SUBJECT PHOTOGRAPHS")
		move_down 10
		if @docs[:photos][2]
			image_cap("")
			image "#{@docs[:photos][2]}", width: 300, position: :center
			move_down 2
			text "Subject Property - Representative Image", align: :center
			move_down 25
		else
			text "No Image", align: :center
			move_cursor_to 350
		end

		if @docs[:photos][3]
			image_cap("")
			image "#{@docs[:photos][3]}", width: 300, position: :center
			move_down 2
			text "Subject Property - Representative Image", align: :center
			move_down 25
		else
			text "No Image", align: :center
			move_cursor_to 350
		end
	else
		text "No Image", align: :center
		move_cursor_to 350
		text "No Image", align: :center
		move_cursor_to 350
		start_new_page
		text "No Image", align: :center
		move_cursor_to 350
		text "No Image", align: :center
		move_cursor_to 350
	end

	start_new_page
end

#table_of_contentsObject



216
217
218
219
# File 'lib/eval_report.rb', line 216

def table_of_contents
	header("TABLE OF CONTENTS")
	start_new_page
end

#topo_mapsObject



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/eval_report.rb', line 343

def topo_maps
	header("SUBJECT MAPS")
	move_down 25
	text "MAPS", size: 14, align: :center

	if @docs[:topomap] && @docs[:topomap].any?
		if @docs[:topomap][0]
			image_cap("TOPOGRAPHICAL MAP")
			image "#{@docs[:topomap][0]}", width: 300, position: :center
			move_down 25
		else
			text 'No Image', align: :center
			move_cursor_to 350
		end


		if @docs[:aerialmap] && @docs[:aerialmap][0]
			image_cap("AERIAL FSA MAP")
			image "#{@docs[:aerialmap][0]}", width: 300, position: :center
		else
			text 'No Image', align: :center
		end
	else
		text 'No Image', align: :center
		move_cursor_to 350
		text 'No Image', align: :center
	end
	start_new_page
end

#transaction_historyObject

table methods for the property_features_method



1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
# File 'lib/eval_report.rb', line 1135

def transaction_history
	transaction_history_data = [
		[{content: "Transaction History", colspan: 4}],
		["Historic Transaction Type", "Transaction Description", "Date", "Sale Price, List Price, or List Price"]
	]

	transactions = @sub[:historyrecords]

	if transactions # node could be nil
		transactions.each do |t|
			if t # array could be nil
				transaction_history_data.push(
					["#{t[:transType]}", "#{t[:transDescr]}", datemaker(t[:transDate]), moneymaker(t[:price], true)]
				)
			end
		end
	end

	table(transaction_history_data) do
		columns(0..3).width = 135
		columns(0..3).style(align: :right, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
end

#utilitiesObject



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/eval_report.rb', line 1163

def utilities
	utilities_data = [
		[{content: "Description of Utilities", colspan: 4}],
		["Utility Description", "Service Availability", "Service Provider", "Comments"]
	]

	utilities = @sub[:utilities]
	if utilities # node could be nil
		utilities.each do |u|
			if u # array could be empty
				utilities_data.push(
					["#{u[:description]}", "#{u[:availability]}", "#{u[:provider]}", "#{u[:comments]}"]
				)
			end
		end
	end

	table(utilities_data) do
		columns(0..3).width = 135
		columns(0..3).style(align: :right, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
end

#val_method_and_reconObject



862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/eval_report.rb', line 862

def val_method_and_recon
	header("FINAL VALUE INDICATION")
	move_down 25
	text "Valuation Methodology Review and Reconciliation", size: 14, style: :bold
	move_down 20
	text @text_blocks[:val_method]
	move_down 10

	indent(50) do
		text "SUMMATION:"
		move_down 10

		# prepare primary land values for calculation
		prepare_comps_for_calc

		improvements = @sub[:improvements]

		if improvements && improvements.any?
			cents = improvements.inject(0) do |memo, improv|
				memo += improv[:depval][:cents]; memo
			end

			total_dep = Money.new(cents, 'USD')
		else
			total_dep = Money.new(0, 'USD')
		end

		# get land class acres for calcs
		if @sub[:landclassifications] && @sub[:landclassifications].any?
				units_primary = @sub[:landclassifications][0][:numacres]

				if @sub[:landclassifications][1]
					units_secondary = @sub[:landclassifications][1][:numacres]
				else
					units_secondary = 0
				end
		else
			units_primary = 0
			units_secondary = 0
		end

		total_acres = @sub[:num_of_units] ? @sub[:num_of_units] : 0.1
		indicated_val = ((median_land_val(@recon_primary_per_acre) * units_primary) + (median_land_val(@recon_secondary_per_acre) * units_secondary)) / total_acres
		overall_val = ((median_land_val(@recon_primary_per_acre) * units_primary) + (median_land_val(@recon_secondary_per_acre) * units_secondary)) + total_dep
		say = Money.new((((overall_val.to_i + 500/2)/500)*500).round(-2) * 100, 'USD')


		parallel_text("Average Primary Land Value/Unit:", "#{average_land_val(@recon_primary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Median Primary Land Value/Unit:", "#{median_land_val(@recon_primary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Maximum Primary Land Value/Unit:", "#{maximum_land_val(@recon_primary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Minimum Primary Land Value/Unit:", "#{minimum_land_val(@recon_primary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Unit of Comparison:", "$/Acre", 200)
		move_down 20

		parallel_text("Aggregate Units:", "#{@sub[:num_of_units]}", 200)
		move_down 20

		parallel_text("Indicated Primary Land Value/Unit",  "#{median_land_val(@recon_primary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Total Primary Land Units:", "#{units_primary}", 200)
		move_down 20

		parallel_text("Indicated Secondary Land Value/Unit:",  "#{median_land_val(@recon_secondary_per_acre).format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Total Secondary Land Units:", "#{units_secondary}", 200)
		move_down 20

		parallel_text("Total Other Units not Analyzed:", "#{no_nil_number(@sub[:num_of_units]) - units_primary - units_secondary}", 200)
		move_down 20

		parallel_text("Indicated Value per Unit in Aggregate", "#{indicated_val.format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Improvement Value Allocation:", "#{total_dep.format(no_cents: true)}", 200)
		move_down 20

		parallel_text("Overall Indicated Value:", "#{overall_val.format(no_cents: true)}", 200)
		move_down 20

		parallel_text("SAY (Rounded):", "#{say.format(no_cents: true)}", 200)
		start_new_page
	end
end

#value_introObject



731
732
733
734
735
736
737
738
739
740
741
742
743
744
# File 'lib/eval_report.rb', line 731

def value_intro
	header("VALUATION PROCESS")
	move_down 25
	text "VALUATION PROCESS", size: 14, style: :bold
	move_down 20
	text "#{@text_blocks[:valuation_process]}"


	move_down 25
	text "ESTIMATE OF VALUE BY DIRECT COMPARISON METHODOLOGY", size: 14, style: :bold
	move_down 20
	text "#{@text_blocks[:comp_method]}"
	start_new_page
end

#water_distributionObject



1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
# File 'lib/eval_report.rb', line 1234

def water_distribution
	distribution_data = [
		[{content: "Water Distribution System", colspan: 8}],
		["Water Distrib. Equip.", "Manuf.", "Make/Brand", "Type", "Description", "Yr. Manufactured", "Remaining Ec. Life", "No. Acres Irrigated"]
	]

	distributions = @sub[:waterdistributions]

	if distributions # node could be nil
		distributions.each do |d|
			if d # array could be empty
				distribution_data.push(
					["#{d[:waterdistrEq]}", "#{d[:manufacturer]}", "#{d[:brand]}", "#{d[:eqType]}", "#{d[:descr]}", "#{d[:yearManuf]}", "#{d[:remainingEcLife]}", "#{d[:irrAcres]}"]
				)
			end
		end
	end

	table(distribution_data) do
		columns(0..7).width = 67.5
		columns(0..7).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
end

#water_rightsObject



1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
# File 'lib/eval_report.rb', line 1206

def water_rights
	water_rights_data = [
		[{content: "Water Rights", colspan: 8}],
		["Water Right No.", "Water Right", "Water Source", "Priority Date", "Beneficial Use", "No. Acres Irrigated", "Annual Volume Ac-Ft", "Period of Use"]
	]

	rights = @sub[:waterrights]
	if rights # node could be nil
		rights.each do |r|
			if r # array could be empty
				water_rights_data.push(
					["#{r[:waterrightNum]}", "#{r[:waterRight]}", "#{r[:waterSrc]}", datemaker(r[:priorityDate]), "#{r[:purpose]}", "#{r[:numIrrAcres]}", "#{r[:annVolume]}"]
				)
			end
		end
	end

	table(water_rights_data) do
		columns(0..7).width = 67.5
		columns(0..7).style(font_style: :bold)
		row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
		cells.padding = [1, 2.5]
		cells.style(border_width: 0)
		row(1).style(border_bottom_width: 0.5, font_style: nil)
	end
	# no new page
end

#write_content(subject, comparables, logo, docs = {}) ⇒ Object

main method to populate pdf



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/eval_report.rb', line 13

def write_content(subject, comparables, , docs={}) # main method to populate pdf
	# variables used across instance methods
	@logo = 
	@sub = subject
	@comps = comparables
	@comps ||= [] # avoid calling methods on nil
	@docs = docs
	@docs ||= {}
	@text_blocks = static_strings # Hash of text blocks loaded from .yml
	@recon_primary_per_acre = [] # used for reconciliation for comparables
	@recon_secondary_per_acre = [] # ""

	# hash for building table of contents from headers/page numbers
	@toc_hash = {}

	# font defaults to Helvetica
	font_size 11 

	
	cover_page
	letter_of_transmittal # table/text
	subject_images #images with caption # 2 pages
	table_of_contents #text
	introduction #text and checkboxes
	property_identification
	regional_maps
	topo_maps
	property_description
	property_features
	value_intro
	property_comparison # landscape
	discussion_of_sales # landscape
	ag_sales_map
	val_method_and_recon
	assumptions_and_conditions
	additional_docs
	finish_toc
end