Class: ClosedSale

Inherits:
Prawn::Document
  • Object
show all
Includes:
ReportUtils
Defined in:
lib/closed_sale.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

#initializeClosedSale

Returns a new instance of ClosedSale.



8
9
10
# File 'lib/closed_sale.rb', line 8

def initialize()
  super()
end

Instance Method Details

#additional_imagesObject



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
729
730
# File 'lib/closed_sale.rb', line 703

def additional_images
  if @property_images && @property_images.count > 1
    start_new_page
    if @property_images[1]
      bounding_box([0, 690], height: 330, width: 250) do
        image @property_images[1], width: 240
      end
    end

    if @property_images[2]
      bounding_box([270, 690], height: 330, width: 250) do
        image @property_images[2], width: 240
      end
    end

    if @property_images[3]
      bounding_box([0, 340], height: 330, width: 250) do
        image @property_images[3], width: 240
      end
    end

    if @property_images[4]
      bounding_box([270, 340], height: 330, width: 250) do
        image @property_images[4], width: 240
      end
    end
  end
end

#cash_flowObject



265
266
267
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
# File 'lib/closed_sale.rb', line 265

def cash_flow
  cash_flow_data = [
    [{content: "Cash Flow - Production Analysis", colspan: 4}],
    ["Income Source", "Stable $/Unit", "Stablilized Yield/Unit", "No. of Source, i.e. AC"]
  ]

  incomes = @rep[:incomes]

  if incomes # node could be nil
    incomes.each do |i|
      if i # array could be nil
        cash_flow_data.push(
          [
            i[:incomesrc],
            moneymaker(i[:stabcashperunit], false),
            '%.2f' % no_nil_number(i[:stabilizedyield]),
            '%.2f' % no_nil_number(i[:totalunits])
          ]
        )
      end
    end
  end

  table(cash_flow_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns(1..3).style(align: :right, font_style: :bold)
    column(0).style(align: :left, font_style: :bold)
    row(0).style(align: :center, background_color: 'd7d7d7', size: 11, border_top_width: 0.5)
    cells.style(border_width: 0)
    row(1).style(border_bottom_width: 0.5, align: :center, font_style: nil)
    cells.padding = [1, 2.5]
  end
end

#commentsObject



300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/closed_sale.rb', line 300

def comments
  comments_data = [
    ["Comments"],
    ["#{@rep[:general_comments]}"]
  ]

  table(comments_data) do
    row(0).style align: :center
    column(0).width = 270
    cells.padding = [1, 2.5]
    cells.style(border_width: 0)
    row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
  end
end

#crop_yieldObject



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
# File 'lib/closed_sale.rb', line 609

def crop_yield
  crops = @rep[: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

#estimated_productivityObject



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
# File 'lib/closed_sale.rb', line 638

def estimated_productivity
  estimatedproductivity = @rep[:estimatedproductivity]

  production_data = [
    [{content: "Estimated Productivity", colspan: 4}],
    ["Commodity Identification", "Unit Measure", "Estimated Yield", " "]
  ]

  if estimatedproductivity && estimatedproductivity.any?
    estimatedproductivity.each do |p|
      production_data.push(
        ["#{p[:commodity]}", "#{p[:unit]}", "#{p[:estmtdyield]}"]
      )
    end
  end

  table(production_data) do
    columns(0..3).width = 135
    columns(0..3).style(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

#externalitiesObject



692
693
694
695
696
697
698
699
700
701
# File 'lib/closed_sale.rb', line 692

def externalities
  extern_data = ReportUtils.conditional_externs_array(@rep) # 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', size: 11, font_style: :bold)
    cells.padding = [1, 2.5]
    cells.style(border_width: 0)
  end
end

#improvementsObject



539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/closed_sale.rb', line 539

def improvements
  improvements_array = @rep[: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 
end

#income_expenseObject



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
# File 'lib/closed_sale.rb', line 419

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

  income_expense_data = [
    [{content: "Income/Expense Information", colspan: 4}],
    ["Total Farm Income:", income.format(no_cents: true), "Total Income to LL:", income.format(no_cents: true)],
    ["Total Farm Expenses:", expense.format(no_cents: true), "Total Exp pd by LL:", expense.format(no_cents: true)],
    ["NOI:", noi_string, "Expense Ratio:", expense_ratio],
    ["Cap Rate or OAR", "#{@rep[:overall_capitalization_rate]}%", " ", " "],
    [{content: "Cash Flow Comments:", colspan: 4}],
    [{content: @rep[:income_comments], colspan: 4}],
    ["Annual Water $/Acre:", moneymaker(@rep[:irrig_cost_per_acre], true)],
    ["Annual Pumping $/Acre:", moneymaker(@rep[:pumping_cost_per_acre], true)]
  ]

  table(income_expense_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns(0..3).style(align: :right)
    cells.padding = [1, 2.5]
    cells.style(border_width: 0)
    columns([1, 3]).style(font_style: :bold)
    row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
    row([5, 6]).style(align: :left)
  end
end

#land_classificationObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
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
# File 'lib/closed_sale.rb', line 197

def land_classification
  classification_data = [
    [{content: "Land Classification Breakdown", colspan: 4}],
    ["Land Class:", "Acres:", "$/Acre:", "Total:"],
  ]

  land_classes = @rep[:landclassifications]
  if land_classes # node could be nil

    total_acres = 0 # value to add to in loop
    total_dollar = 0

    land_classes.each do |l|
      if l # array could be empty
        if l[:priceperacre] # priceperacre could be nil, avoid nomethod errors below by checking
          m = Money.new(l[:priceperacre][:cents], l[:priceperacre][:currency_iso])
          per_acre_string = m.format(no_cents: true)
          total_string = (m * l[:numacres]).format(no_cents: true)

          total_acres += no_nil_number(l[:numacres]) # add to total
          total_dollar += m.to_f * l[:numacres]

          classification_data.push(
            [
              "#{l[:landclass]}", 
              '%.2f' % no_nil_number(l[:numacres]), # => adds .00 to acres
              per_acre_string,
              total_string
            ]
          )
        end
      end
    end # end block

    total_dollar_string = Money.new(total_dollar * 100, 'USD').format(no_cents: true)
    total_per_acre = Money.new((total_dollar / total_acres) * 100, 'USD')
    total_per_acre_string = total_per_acre.format(no_cents: true)
    
    # push totals into table
    classification_data.push(
      ["", "", "", ""], # line space
      ["Totals", '%.2f' % total_acres, total_per_acre_string, total_dollar_string]
    )

    if @rep[:imprv_unitprice]
      improv_alloc = Money.new(@rep[:imprv_unitprice][:cents], 'USD')
    else
      improv_alloc = Money.new(0, 'USD')
    end

    classification_data.push([
      "Total $ to Imprv", moneymaker(@rep[:total_imprv_budget], true), 
      "Imprv $/AC Alloc", improv_alloc.format(no_cents: :true)],
      [{content: "Total Land and Improvement $/AC", colspan: 3}, (total_per_acre + improv_alloc).format(no_cents: :true)])
  end

  table(classification_data) do # land classification breakdown table
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns(1..3).style(align: :right)
    cells.style(border_width: 0)
    cells.padding = [1, 2.5]
    row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
    row(1).style(align: :right, font_style: :bold, border_bottom_width: 0.5)
    row(-3).style(border_bottom_width: 0.5, font_style: :bold)
  end
end


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
# File 'lib/closed_sale.rb', line 450

def legal_transaction
  taxes = @rep[:taxes]
  if taxes # node could be nil
    if taxes[0] # array could be empty
      tax_parcel_no = taxes[0][:tax_parcel_no]
      assessed_value = moneymaker(taxes[0][:assessed_value], true)
      real_estate_taxes = moneymaker(taxes[0][:RET], true)
    end
  else # deal with nil values to avoid no method errors
    tax_parcel_no, assessed_value, real_estate_taxes = "", "", ""
  end

  legal_transaction_data = [
    [{content: "Legal/Transaction Detail", colspan: 4}],
    ["Tax Parcel ID(s)", tax_parcel_no, " ", " "],
    [" ", " ", " ", " "],
    ["Year of Assessment:", "#{@rep[:year_of_assessment]}", "Year of RE Taxes:", "#{@rep[:year_of_real_estate_taxes]}"],
    ["Assessed Value:", assessed_value, "RE Taxes", real_estate_taxes],
    ["Financing:", "#{@rep[:financing_type]}", "Property Rights:", "#{@rep[:property_rights]}"],
    ["At Market Trans?:", "#{@rep[:atmarket_trans]}", "Days on Market:", "#{@rep[:exposure_period]}"],
    [{content: "Transaction History Comments:", colspan: 4}],
    [{content: "#{@rep[:listing_comments]}", colspan: 4}]
  ]

  table(legal_transaction_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns([1, 3]).style(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)
  end
end

#meta_dataObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/closed_sale.rb', line 167

def 
   = [
    ["Record Number:", "#{@rep[:sequence]}"], 
    ["Record Created By:", "#{@rep[:record_created_by]}"],
    ["Date Created or Last Modified:", datemaker(@rep[:record_edited])]
  ]
  
  table() do # record meta data table with image
    columns(0..1).width = 135
    columns([0]).style(font_style: :bold)
    cells.style(border_width: 0)
    cells.padding = [1, 2.5]
  end
end

#perm_plantingsObject



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/closed_sale.rb', line 664

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 = @rep[: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

#physical_overviewObject



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
# File 'lib/closed_sale.rb', line 391

def physical_overview
  overview_data = [
    [{content: "Physical Overview", colspan: 4}],
    ["Farming Practice:", "#{@rep[:farming_practices]}", {content: "Predominant Soil Type and Description:", colspan: 2}],
    ["Ann. Rainfall-Inches:", "#{@rep[:avg_precipitation]}", {content: "#{@rep[:soils]}", colspan: 2, rowspan: 3}],
    ["Avg Frost Free Days:", "#{@rep[:growing_season]}"],
    ["Elevation(Range):", "#{@rep[:elevation]}"],
    ["Predom Top Slope:", "#{@rep[:topography]}", "Legal Access:", {content: "#{@rep[:legal_access]}", rowspan: 2}],
    ["Corn Suitability Rating:", @rep[:CSR2]],
    ["Land Use Zone:", "#{@rep[:land_use_zone]}", "Physical Access:", "#{@rep[:physical_access]}"],
    ["Flood Zone:", no_nil_array(@rep[:flood_zone]).join(", "), "Wetlands:", "#{@rep[:wetlands]}"],
    [{content: "Land Development Potential, Change or Use, or Limitations Comments:", colspan: 4}],
    [{content: "#{@rep[:development_potential]}" , colspan: 4}]
  ]

  table(overview_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns([0, 2]).style(align: :right)
    columns([1, 3]).style(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(9).style(align: :left)
    row(-1).style(align: :left)
  end
end

#profile_imageObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/closed_sale.rb', line 182

def profile_image
  if @property_images && @property_images.any?
    image "#{@property_images.first}", width: 265
  else
    text "No Image"
  end

  table([["Property Location and Directions:"], ["#{@rep[:directions_or_ownership_comments]}"]]) do
    cells.padding = [1, 2.5]
    cells.style(border_width: 0)
    column(0).width = 270
    row(0).style(align: :center, background_color: 'd7d7d7', font_style: :bold)
  end
end

#property_classObject



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/closed_sale.rb', line 315

def property_class
  property_data = [
    ["Property Classification:", "#{@rep[:land_use_zone]}"],
    ["Transaction Type:", "#{@rep[:type_of_transaction]}"],
    ["Property Name:", "#{@rep[:property_name]}"]
  ]

  table(property_data) do
    column(0).style(align: :right)
    column([1]).style(font_style: :bold)
    columns(0..1).width = 135
    cells.style(border_width: 0)
    cells.padding = [1, 2.5]
  end
end

#property_type_and_addressObject



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/closed_sale.rb', line 331

def property_type_and_address
  pos = @rep[:position] # lat and long
  if pos
    lat, long = pos[0], pos[1]
  else
    lat, long = " ", " "
  end

  property_inclusions = no_nil_array(@rep[:property_inclusions]).join(" ")
  type_and_address_data = [
    [{content: "Property Type and Address", colspan: 4}],
    ["Property Name:", "#{@rep[:property_name]}", "Primary Land Use:", "#{@rep[:primary_ag_use]}"],
    ["What does this property include?", 
      {content: property_inclusions, colspan: 3}],
    ["Address:", {content: "#{@rep[:property_address_number]}" + " #{@rep[:street_or_road_name]}", colspan: 3}],
    ["City:", "#{@rep[:city]}", "County:", "#{@rep[:ordinance_authority]}"],
    ["State:", "#{@rep[:county_state]}".strip.split('').last(2).join(""), "Zip Code:", "#{@rep[:zip_code]}"],
    ["Township/Range:","#{@rep[:townshipINT]}" + "#{@rep[:rangeINT]}", "Section(s):", "#{@rep[:legal_description]}"],
    ["Latitude:", lat, "Longitude:", long]
  ]

  table(type_and_address_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns([0, 2]).style(align: :right)
    columns([1, 3]).style(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)
  end
end

#render_logoObject



160
161
162
163
164
# File 'lib/closed_sale.rb', line 160

def 
  if 
    image , height: 35
  end
end

#transaction_historyObject



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
# File 'lib/closed_sale.rb', line 484

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 = @rep[: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

#transaction_summaryObject



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/closed_sale.rb', line 363

def transaction_summary
  price = moneymaker(@rep[:sale_price], true)
  adjustment = moneymaker(@rep[:sale_adjustment], true)
  ce_sale_price = moneymaker(@rep[:cesaleprice], true)
  transaction_data = [
    [{content: "Transaction Summary", colspan: 4}],
    ["Sale Price $:", price, "Sale Date:", datemaker(@rep[:sale_date])],
    ["Cond. Adjust $:", '(' + adjustment +')', "Adj. CE Sale $:", ce_sale_price],
    ["Unit Description:", "#{@rep[:unit]}", "No. of Units:", '%.2f' % no_nil_number(@rep[:num_of_units])],
    ["Instrument No.:", "#{@rep[:public_rec_ref_numer]}", "$/Unit:", moneymaker(@rep[:cesaleunitprice], true)],
    ["Seller:", "#{@rep[:grantor]}", "Buyer:", "#{@rep[:grantee]}"],
    ["Extent of Verification:", {content: no_nil_array(@rep[:verifications]).join(', '), colspan: 3}],
    [{content: "#{@rep[:grantor]}" + " #{@rep[:information_source_contact]}", 
      colspan: 2}, "Date Inspected:", datemaker(@rep[:date_inspected])
    ]
  ]

  table(transaction_data) do
    columns(0..1).width = 68
    columns(2..3).width = 67
    columns([0, 2]).style align: :right
    cells.padding = [1, 2.5]
    cells.style(border_width: 0)
    columns([1, 3]).style(font_style: :bold)
    row(0).style(align: :center, background_color: 'd7d7d7', size: 11, font_style: :bold)
  end
end

#utilitiesObject



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
# File 'lib/closed_sale.rb', line 512

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

  utilities = @rep[: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

#water_distributionObject



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
# File 'lib/closed_sale.rb', line 581

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 = @rep[: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



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
# File 'lib/closed_sale.rb', line 554

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 = @rep[: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
end

#write_content(report_doc, images, office_logo) ⇒ Object

the call to add content to pdf



12
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
51
52
53
54
55
56
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
109
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
149
150
151
152
153
154
155
156
157
158
# File 'lib/closed_sale.rb', line 12

def write_content(report_doc, images, ) # the call to add content to pdf
  font_size 7
  @rep = report_doc
  @property_images = images
   = 
  
  ## page 1 ##

  # render office logo image if present
  stroke_bounds
  move_down 10
  

  # rendering tables
  float do
    
  end

  indent(270) do
    property_class
  end

  move_down 5
  stroke_horizontal_rule
  move_down 5
  float do
    profile_image
  end

  indent(270) do
    property_type_and_address
    transaction_summary
  end

  move_down 25
  stroke_horizontal_rule
  move_down 5
  float do
    land_classification
  end

  indent(270) do
    physical_overview
  end

  move_down 15
  stroke_horizontal_rule
  move_down 5
  float do
    cash_flow
  end

  indent(270) do
    income_expense
  end

  stroke_line [270, 720], [270, 0]

  if page_count == 1
    start_new_page
  end

  ## page 2 ##
  stroke_horizontal_rule
  stroke_bounds
  move_down 5
  float do
    comments
  end
  
  indent(270) do
    legal_transaction
  end

  # stroke boundary line
  stroke_line [270, 720], [270, cursor]
  move_down 30
  stroke_horizontal_rule
  move_down 5
  # move to full width table
  if @rep[:transactions] && @rep[:transactions].any?
    transaction_history
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

  if @rep[:utilities] && @rep[:utilities].any?
    utilities
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

  if @rep[:improvements] && @rep[:improvements].any?
    improvements
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

  if @rep[:waterrights] && @rep[:waterrights].any?
    water_rights
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

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

  if @rep[:estimatedproductivity] && @rep[:estimatedproductivity].any?
    estimated_productivity
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

  # stroke bounds again for third page
  

  if @rep[:plantings] && @rep[:plantings].any?
    perm_plantings
    move_down 30
    stroke_horizontal_rule
    move_down 5
  end

  stroke_bounds
  externalities
  
  ## page 4 ##
  additional_images


end