appraisermetrics_report_service 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/report_utils.rb CHANGED
@@ -57,33 +57,33 @@ module ReportUtils
57
57
  end
58
58
  module_function :parallel_text
59
59
 
60
- def average_primary_land_val(comp_values) # averages an array of floats
60
+ def average_land_val(comp_values) # averages an array of floats
61
61
  sum = comp_values.inject(:+)
62
62
  ave = sum ? sum / comp_values.count : 0
63
63
  return Money.new(ave * 100, 'USD')
64
64
  end
65
- module_function :average_primary_land_val
65
+ module_function :average_land_val
66
66
 
67
- def median_primary_land_val(comp_values) # gets median value for an array of floats
67
+ def median_land_val(comp_values) # gets median value for an array of floats
68
68
  sorted_array = comp_values.sort
69
69
  length = sorted_array.length
70
70
 
71
71
  median = sorted_array.any? ? (sorted_array[(length - 1) / 2] + sorted_array[length / 2]) / 2.0 : 0
72
72
  return Money.new(median * 100, 'USD')
73
73
  end
74
- module_function :median_primary_land_val
74
+ module_function :median_land_val
75
75
 
76
- def maximum_primary_land_val(comp_values) # gets max value for array of floats
76
+ def maximum_land_val(comp_values) # gets max value for array of floats
77
77
  max = comp_values.any? ? comp_values.max : 0
78
78
  return Money.new(max * 100, 'USD')
79
79
  end
80
- module_function :maximum_primary_land_val
80
+ module_function :maximum_land_val
81
81
 
82
- def minimum_primary_land_val(comp_values) # gets min value for array of floats
82
+ def minimum_land_val(comp_values) # gets min value for array of floats
83
83
  min = comp_values.any? ? comp_values.min : 0
84
84
  return Money.new(min * 100, 'USD')
85
85
  end
86
- module_function :minimum_primary_land_val
86
+ module_function :minimum_land_val
87
87
 
88
88
  def flip_improvements_array(improv_array)
89
89
  type, size, unit_of_measure, foundation, const_class = ["Type"], ["Size"], ["Unit of Measure"], ["Foundation"], ["Const. Class"]
@@ -1,11 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'eval report class' do
4
+
4
5
  describe '#meta_data' do
5
6
  context 'with keys' do
6
7
  it 'renders static content' do
7
8
  @pdf = EvalReport.new do
8
- @sub = {foo: 'bar'}
9
+ @sub = {}
9
10
  cover_page
10
11
  end
11
12
 
@@ -27,7 +28,7 @@ describe 'eval report class' do
27
28
  context 'without keys' do
28
29
  it 'renders static content' do
29
30
  @pdf = EvalReport.new do
30
- @sub = {foo: 'bar'}
31
+ @sub = {}
31
32
  cover_page
32
33
  end
33
34
 
@@ -65,7 +66,7 @@ describe 'eval report class' do
65
66
  context 'without keys' do
66
67
  it 'renders static content' do
67
68
  @pdf = EvalReport.new do
68
- @sub = {foo: 'bar'}
69
+ @sub = {}
69
70
  @text_blocks = static_strings
70
71
  letter_of_transmittal
71
72
  end
@@ -105,7 +106,7 @@ describe 'eval report class' do
105
106
  context 'without keys' do
106
107
  it 'renders static content' do
107
108
  @pdf = EvalReport.new do
108
- @sub = {foo: 'bar'}
109
+ @sub = {}
109
110
  @text_blocks = static_strings
110
111
  introduction
111
112
  end
@@ -142,7 +143,7 @@ describe 'eval report class' do
142
143
  context 'without keys' do
143
144
  it 'renders static content' do
144
145
  @pdf = EvalReport.new do
145
- @sub = {foo: 'bar'}
146
+ @sub = {}
146
147
  property_identification
147
148
  end
148
149
 
@@ -169,7 +170,7 @@ describe 'eval report class' do
169
170
  context 'without keys' do
170
171
  it 'renders static content' do
171
172
  @pdf = EvalReport.new do
172
- @sub = {foo: 'bar'}
173
+ @sub = {}
173
174
  @images = {}
174
175
  regional_maps
175
176
  end
@@ -184,7 +185,7 @@ describe 'eval report class' do
184
185
  context 'with keys' do
185
186
  it 'renders image headers' do
186
187
  @pdf = EvalReport.new do
187
- @sub = {foo: 'bar'}
188
+ @sub = {}
188
189
  @images = Sampler.sample_eval_images
189
190
  topo_maps
190
191
  end
@@ -197,7 +198,7 @@ describe 'eval report class' do
197
198
  context 'without keys' do
198
199
  it 'renders static content' do
199
200
  @pdf = EvalReport.new do
200
- @sub = {foo: 'bar'}
201
+ @sub = {}
201
202
  @images = {}
202
203
  topo_maps
203
204
  end
@@ -287,45 +288,6 @@ describe 'eval report class' do
287
288
  end
288
289
  end
289
290
 
290
- describe '#comp_methodology' do
291
- context 'with text blocks' do
292
- it 'renders static content' do
293
- @pdf = EvalReport.new do
294
- @sub = {}
295
- @text_blocks = {comp_method: 'methodology statement'}
296
- comp_methodology
297
- end
298
-
299
- @method_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
300
- expect(@method_content).to include('DIRECT', 'METHODOLOGY', 'ESTIMATE')
301
- end
302
-
303
- it 'renders dynamic content from keys' do
304
- @pdf = EvalReport.new do
305
- @sub = {}
306
- @text_blocks = {comp_method: 'methodology statement'}
307
- comp_methodology
308
- end
309
-
310
- @method_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
311
- expect(@method_content).to include('methodology statement')
312
- end
313
- end
314
-
315
- context 'without text blocks' do
316
- it 'renders static content' do
317
- @pdf = EvalReport.new do
318
- @sub = {}
319
- @text_blocks = {}
320
- comp_methodology
321
- end
322
-
323
- @method_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
324
- expect(@method_content).to include('DIRECT', 'METHODOLOGY', 'ESTIMATE')
325
- end
326
- end
327
- end
328
-
329
291
  describe '#property_comparison' do
330
292
  context 'with keys' do
331
293
  it 'renders static content' do
@@ -406,7 +368,17 @@ describe 'eval report class' do
406
368
  end
407
369
 
408
370
  @discussion_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
409
- expect(@discussion_content).to include('Sale 1')
371
+ expect(@discussion_content).to include('DIRECT')
372
+ end
373
+ end
374
+
375
+ context '@comps is nil' do
376
+ it 'does not break if @comps is nil' do
377
+ @pdf = EvalReport.new do
378
+ @sub = Sampler.get_eval1
379
+ @comps = nil
380
+ discussion_of_sales
381
+ end
410
382
  end
411
383
  end
412
384
  end
@@ -431,6 +403,7 @@ describe 'eval report class' do
431
403
  @text_blocks = {}
432
404
  @comps = []
433
405
  @recon_primary_per_acre = []
406
+ @recon_secondary_per_acre = []
434
407
  6.times {|f| @comps << Sampler.get_comp2}
435
408
  val_method_and_recon
436
409
  end
@@ -439,19 +412,20 @@ describe 'eval report class' do
439
412
  expect(@recon_content).to include('Average', 'Median', 'Maximum')
440
413
  end
441
414
 
442
- #it 'renders dynamic content from keys' do
443
- # @pdf = EvalReport.new do
444
- # @sub = Sampler.get_eval1
445
- # @text_blocks = {}
446
- # @comps = []
447
- # @recon_primary_per_acre = []
448
- # 6.times {|f| @comps << Sampler.get_comp2}
449
- # val_method_and_recon
450
- # end
451
- #
452
- # # @recon_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
453
- # # expect(@recon_content).to include('stff')
454
- #end
415
+ it 'renders dynamic content from keys' do
416
+ @pdf = EvalReport.new do
417
+ @sub = Sampler.get_eval1
418
+ @text_blocks = {}
419
+ @comps = []
420
+ @recon_primary_per_acre = []
421
+ @recon_secondary_per_acre = []
422
+ 6.times {|f| @comps << Sampler.get_comp2}
423
+ val_method_and_recon
424
+ end
425
+
426
+ @recon_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
427
+ expect(@recon_content).to include('$7,500')
428
+ end
455
429
  end
456
430
 
457
431
  context 'without keys' do
@@ -461,6 +435,7 @@ describe 'eval report class' do
461
435
  @text_blocks = {}
462
436
  @comps = []
463
437
  @recon_primary_per_acre = []
438
+ @recon_secondary_per_acre = []
464
439
  val_method_and_recon
465
440
  end
466
441
 
@@ -474,6 +449,7 @@ describe 'eval report class' do
474
449
  @text_blocks = {val_method: 'value text'}
475
450
  @comps = []
476
451
  @recon_primary_per_acre = []
452
+ @recon_secondary_per_acre = []
477
453
  val_method_and_recon
478
454
  end
479
455
 
@@ -509,18 +485,80 @@ describe 'eval report class' do
509
485
 
510
486
  describe '#addendum_a' do
511
487
  context 'with keys' do
512
- it 'renders static content'
488
+ it 'renders static content' do
489
+ @pdf = EvalReport.new do
490
+ @sub = Sampler.get_eval1
491
+ @docs = {engagement_letter: './spec/test_data/pdfs/engagement_letter.pdf'}
492
+ addendum_a
493
+ end
513
494
 
514
- it 'renders dynamic content from keys'
495
+ @addendum_a_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
496
+ expect(@addendum_a_content).to include('ENGAGEMENT')
497
+ end
498
+
499
+ it 'renders dynamic content from keys' do
500
+ @pdf = EvalReport.new do
501
+ @sub = Sampler.get_eval1
502
+ @docs = {engagement_letter: './spec/test_data/pdfs/engagement_letter.pdf'}
503
+ addendum_a
504
+ end
505
+
506
+ @addendum_a_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
507
+ expect(@addendum_a_content).to include('test')
508
+ end
515
509
  end
516
510
 
517
511
  context 'without keys' do
518
- it 'renders static content'
512
+ it 'renders static content' do
513
+ @pdf = EvalReport.new do
514
+ @sub = {}
515
+ @docs = {}
516
+ addendum_a
517
+ end
518
+
519
+ @addendum_a_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
520
+ expect(@addendum_a_content).to include('ENGAGEMENT', 'present')
521
+ end
519
522
  end
520
523
  end
521
524
 
522
525
  describe '#addendum_b' do
526
+ context 'with keys' do
527
+ it 'renders static content' do
528
+ @pdf = EvalReport.new do
529
+ @sub = {}
530
+ @docs = {legal_description: './spec/test_data/pdfs/legal_description.pdf'}
531
+ addendum_b
532
+ end
533
+
534
+ @addendum_b_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
535
+ expect(@addendum_b_content).to include('LEGAL')
536
+ end
537
+
538
+ it 'renders inserts dynamic content from pdf' do
539
+ @pdf = EvalReport.new do
540
+ @sub = Sampler.get_eval1
541
+ @docs = {legal_description: './spec/test_data/pdfs/legal_description.pdf'}
542
+ addendum_b
543
+ end
544
+
545
+ @addendum_b_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
546
+ expect(@addendum_b_content).to include('test')
547
+ end
548
+ end
549
+
550
+ context 'without keys' do
551
+ it 'renders static content' do
552
+ @pdf = EvalReport.new do
553
+ @sub = Sampler.get_eval1
554
+ @docs = {}
555
+ addendum_b
556
+ end
523
557
 
558
+ @addendum_b_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(2).to_s
559
+ expect(@addendum_b_content).to include('LEGAL')
560
+ end
561
+ end
524
562
  end
525
563
 
526
564
  describe '#header' do
@@ -551,7 +589,7 @@ describe 'eval report class' do
551
589
  context 'without keys' do
552
590
  it 'renders static content' do
553
591
  @pdf = EvalReport.new do
554
- @sub = {foo: 'bar'}
592
+ @sub = {}
555
593
  transaction_history
556
594
  end
557
595
  @transaction_history_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -582,7 +620,7 @@ describe 'eval report class' do
582
620
  context 'without keys' do
583
621
  it 'renders static content' do
584
622
  @pdf = EvalReport.new do
585
- @sub = {foo: 'bar'}
623
+ @sub = {}
586
624
  utilities
587
625
  end
588
626
  @utilities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -613,7 +651,7 @@ describe 'eval report class' do
613
651
  context 'without keys' do
614
652
  it 'renders static content' do
615
653
  @pdf = EvalReport.new do
616
- @sub = {foo: 'bar'}
654
+ @sub = {}
617
655
  improvements
618
656
  end
619
657
 
@@ -646,7 +684,7 @@ describe 'eval report class' do
646
684
  context 'without keys' do
647
685
  it 'renders static content' do
648
686
  @pdf = EvalReport.new do
649
- @sub = {foo: 'bar'}
687
+ @sub = {}
650
688
  water_rights
651
689
  end
652
690
  @water_rights_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -680,7 +718,7 @@ describe 'eval report class' do
680
718
  context 'without keys' do
681
719
  it 'renders static content' do
682
720
  @pdf = EvalReport.new do
683
- @sub = {foo: 'bar'}
721
+ @sub = {}
684
722
  water_distribution
685
723
  end
686
724
  @water_distribution_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -712,7 +750,7 @@ describe 'eval report class' do
712
750
  context 'without keys' do
713
751
  it 'renders static content' do
714
752
  @pdf = EvalReport.new do
715
- @sub = {foo: 'bar'}
753
+ @sub = {}
716
754
  crop_yield
717
755
  end
718
756
  @crop_yield_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -744,7 +782,7 @@ describe 'eval report class' do
744
782
  context 'without keys' do
745
783
  it 'renders static content' do
746
784
  @pdf = EvalReport.new do
747
- @sub = {foo: 'bar'}
785
+ @sub = {}
748
786
  perm_plantings
749
787
  end
750
788
  @perm_plantings_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -776,7 +814,7 @@ describe 'eval report class' do
776
814
  context 'without keys' do
777
815
  it 'renders static content' do
778
816
  @pdf = EvalReport.new do
779
- @sub = {foo: 'bar'}
817
+ @sub = {}
780
818
  externalities
781
819
  end
782
820
  @externalities_content = PDF::Reader.new(StringIO.new(@pdf.render)).page(1).to_s
@@ -788,7 +826,7 @@ describe 'eval report class' do
788
826
  describe '#image_cap' do
789
827
  it 'renders title text' do
790
828
  @pdf = EvalReport.new do
791
- @sub = {foo: 'bar'}
829
+ @sub = {}
792
830
  image_cap('Some Title')
793
831
  end
794
832
 
@@ -81,40 +81,40 @@ describe ReportUtils do
81
81
  end
82
82
  end
83
83
 
84
- describe '#average_primary_land_val' do
84
+ describe '#average_land_val' do
85
85
  it 'returns the average of an array of values' do
86
86
  @recon_primary_per_acre = [100, 200, 300, 400, 500, 600]
87
- ave = ReportUtils.average_primary_land_val(@recon_primary_per_acre)
87
+ ave = ReportUtils.average_land_val(@recon_primary_per_acre)
88
88
  expect(ave.format(no_cents: false)).to eq("$350.00")
89
89
  end
90
90
  end
91
91
 
92
- describe '#median_primary_land_val' do
92
+ describe '#median_land_val' do
93
93
  it 'returns the median value for an odd numbered array' do
94
94
  @recon_primary_per_acre = [100, 200, 300, 400, 500, 600, 700]
95
- median = ReportUtils.median_primary_land_val(@recon_primary_per_acre)
95
+ median = ReportUtils.median_land_val(@recon_primary_per_acre)
96
96
  expect(median.format(no_cents: false)).to eq("$400.00")
97
97
  end
98
98
 
99
99
  it 'returns the median value for an even numbered array' do
100
100
  @recon_primary_per_acre = [100, 200, 300, 400, 500, 600]
101
- median = ReportUtils.median_primary_land_val(@recon_primary_per_acre)
101
+ median = ReportUtils.median_land_val(@recon_primary_per_acre)
102
102
  expect(median.format(no_cents: false)).to eq("$350.00")
103
103
  end
104
104
  end
105
105
 
106
- describe '#maximum_primary_land_val' do
106
+ describe '#maximum_land_val' do
107
107
  it 'returns the max value in the array' do
108
108
  @recon_primary_per_acre = [100, 200, 300, 400, 500, 600]
109
- max = ReportUtils.maximum_primary_land_val(@recon_primary_per_acre)
109
+ max = ReportUtils.maximum_land_val(@recon_primary_per_acre)
110
110
  expect(max.format(no_cents: false)).to eq("$600.00")
111
111
  end
112
112
  end
113
113
 
114
- describe '#minimum_primary_land_val' do
114
+ describe '#minimum_land_val' do
115
115
  it 'returns the min value in the array' do
116
116
  @recon_primary_per_acre = [100, 200, 300, 400, 500, 600]
117
- min = ReportUtils.minimum_primary_land_val(@recon_primary_per_acre)
117
+ min = ReportUtils.minimum_land_val(@recon_primary_per_acre)
118
118
  expect(min.format(no_cents: false)).to eq("$100.00")
119
119
  end
120
120
  end
@@ -0,0 +1,69 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 89
21
+ >>
22
+ stream
23
+ q
24
+
25
+ BT
26
+ 36 684.46 Td
27
+ /F1.0 30 Tf
28
+ [<7465737420656e676167656d656e74206c6574746572>] TJ
29
+ ET
30
+
31
+ Q
32
+
33
+ endstream
34
+ endobj
35
+ 5 0 obj
36
+ << /Type /Page
37
+ /Parent 3 0 R
38
+ /MediaBox [0 0 612.0 792.0]
39
+ /Contents 4 0 R
40
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
41
+ /Font << /F1.0 6 0 R
42
+ >>
43
+ >>
44
+ >>
45
+ endobj
46
+ 6 0 obj
47
+ << /Type /Font
48
+ /Subtype /Type1
49
+ /BaseFont /Helvetica
50
+ /Encoding /WinAnsiEncoding
51
+ >>
52
+ endobj
53
+ xref
54
+ 0 7
55
+ 0000000000 65535 f
56
+ 0000000015 00000 n
57
+ 0000000109 00000 n
58
+ 0000000158 00000 n
59
+ 0000000215 00000 n
60
+ 0000000354 00000 n
61
+ 0000000532 00000 n
62
+ trailer
63
+ << /Size 7
64
+ /Root 2 0 R
65
+ /Info 1 0 R
66
+ >>
67
+ startxref
68
+ 629
69
+ %%EOF