irs_forms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.document +5 -0
  2. data/Gemfile +18 -0
  3. data/Gemfile.lock +57 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +27 -0
  6. data/Rakefile +50 -0
  7. data/VERSION +1 -0
  8. data/irs_forms.gemspec +110 -0
  9. data/lib/irs_forms/form.rb +57 -0
  10. data/lib/irs_forms/form1096.rb +89 -0
  11. data/lib/irs_forms/form1099.rb +47 -0
  12. data/lib/irs_forms/form1099_int.rb +87 -0
  13. data/lib/irs_forms/form1099_misc.rb +77 -0
  14. data/lib/irs_forms.rb +13 -0
  15. data/spec/assets/copyA_with_data_and_no_template.pdf-0.12.0.pdf +315 -0
  16. data/spec/assets/copyA_with_data_and_template.pdf-0.12.0.pdf +0 -0
  17. data/spec/assets/copyA_with_template.pdf-0.12.0.pdf +0 -0
  18. data/spec/assets/f1096_for_1099int.pdf-0.12.0.pdf +3596 -1
  19. data/spec/assets/f1096_with_data_and_no_template.pdf-0.12.0.pdf +146 -0
  20. data/spec/assets/f1096_with_data_and_template.pdf-0.12.0.pdf +3596 -1
  21. data/spec/assets/f1096_with_data_and_template_offset.pdf-0.12.0.pdf +3596 -1
  22. data/spec/assets/f1096_with_template.pdf-0.12.0.pdf +3503 -1
  23. data/spec/assets/f1099intA_data_and_template.pdf-0.12.0.pdf +0 -0
  24. data/spec/assets/f1099intA_data_and_template_offset.pdf-0.12.0.pdf +0 -0
  25. data/spec/assets/f1099intB_data_and_template.pdf-0.12.0.pdf +0 -0
  26. data/spec/assets/f1099intC_data_and_template.pdf-0.12.0.pdf +0 -0
  27. data/spec/assets/f1099msc1_data_and_template.pdf-0.12.0.pdf +0 -0
  28. data/spec/assets/f1099msc2_data_and_template.pdf-0.12.0.pdf +0 -0
  29. data/spec/assets/f1099mscA_data_and_template.pdf-0.12.0.pdf +0 -0
  30. data/spec/assets/f1099mscA_data_and_template_offset.pdf-0.12.0.pdf +0 -0
  31. data/spec/assets/f1099mscB_data_and_template.pdf-0.12.0.pdf +0 -0
  32. data/spec/assets/f1099mscC_data_and_template.pdf-0.12.0.pdf +0 -0
  33. data/spec/form1096_spec.rb +65 -0
  34. data/spec/form1099_int_spec.rb +52 -0
  35. data/spec/form1099_misc_spec.rb +118 -0
  36. data/spec/irs_forms_spec.rb +5 -0
  37. data/spec/spec_helper.rb +35 -0
  38. data/templates/NOTES +5 -0
  39. data/templates/f1096--2012.pdf +0 -0
  40. data/templates/f1096.pdf +0 -0
  41. data/templates/f1099int--2012.pdf +0 -0
  42. data/templates/f1099int-copyA.pdf +0 -0
  43. data/templates/f1099int-copyB.pdf +0 -0
  44. data/templates/f1099int-copyC.pdf +0 -0
  45. data/templates/f1099msc--2012.pdf +0 -0
  46. data/templates/f1099msc-copy1.pdf +0 -0
  47. data/templates/f1099msc-copy2.pdf +0 -0
  48. data/templates/f1099msc-copyA.pdf +0 -0
  49. data/templates/f1099msc-copyB.pdf +0 -0
  50. data/templates/f1099msc-copyC.pdf +0 -0
  51. metadata +188 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'activesupport'
7
+ gem 'prawn', '>= 0.12.0'
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem 'rake'
13
+ gem "jeweler", ">= 1.8.3"
14
+ gem 'appraisal'
15
+ gem "rspec", ">= 2.8.0"
16
+ gem "rdoc", ">= 3.12"
17
+ gem "bundler", ">= 1.0.0"
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ Ascii85 (1.0.2)
5
+ activesupport (3.2.10)
6
+ i18n (~> 0.6)
7
+ multi_json (~> 1.0)
8
+ afm (0.2.0)
9
+ appraisal (0.5.1)
10
+ bundler
11
+ rake
12
+ diff-lcs (1.1.3)
13
+ git (1.2.5)
14
+ hashery (2.1.0)
15
+ i18n (0.6.1)
16
+ jeweler (1.8.4)
17
+ bundler (~> 1.0)
18
+ git (>= 1.2.5)
19
+ rake
20
+ rdoc
21
+ json (1.7.6)
22
+ multi_json (1.5.0)
23
+ pdf-reader (1.3.0)
24
+ Ascii85 (~> 1.0.0)
25
+ afm (~> 0.2.0)
26
+ hashery (~> 2.0)
27
+ ruby-rc4
28
+ ttfunk
29
+ prawn (0.12.0)
30
+ pdf-reader (>= 0.9.0)
31
+ ttfunk (~> 1.0.2)
32
+ rake (10.0.3)
33
+ rdoc (3.12)
34
+ json (~> 1.4)
35
+ rspec (2.12.0)
36
+ rspec-core (~> 2.12.0)
37
+ rspec-expectations (~> 2.12.0)
38
+ rspec-mocks (~> 2.12.0)
39
+ rspec-core (2.12.2)
40
+ rspec-expectations (2.12.1)
41
+ diff-lcs (~> 1.1.3)
42
+ rspec-mocks (2.12.1)
43
+ ruby-rc4 (0.1.5)
44
+ ttfunk (1.0.3)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ activesupport
51
+ appraisal
52
+ bundler (>= 1.0.0)
53
+ jeweler (>= 1.8.3)
54
+ prawn (>= 0.12.0)
55
+ rake
56
+ rdoc (>= 3.12)
57
+ rspec (>= 2.8.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ryan Winograd
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ = irs_forms
2
+
3
+ Generate IRS forms with your data
4
+
5
+ irs_forms makes it easy to generate forms with data placed in the correct locations. See these examples:
6
+ with template [PDF[https://github.com/ValencePM/irs_forms/blob/master/spec/assets/f1099msc1_data_and_template.pdf-0.12.0.pdf]],
7
+ without template [PDF[https://github.com/ValencePM/irs_forms/blob/master/spec/assets/copyA_with_data_and_no_template.pdf-0.12.0.pdf]].
8
+
9
+ == List of Supported Forms
10
+
11
+ * Form 1096
12
+ * Form 1099 (MSC)
13
+
14
+ == Contributing to irs_forms
15
+
16
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
17
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
18
+ * Fork the project.
19
+ * Start a feature/bugfix branch.
20
+ * Commit and push until you are happy with your contribution.
21
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
22
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2013 Ryan Winograd. See LICENSE.txt for
27
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+ require 'appraisal'
14
+
15
+ require 'jeweler'
16
+ Jeweler::Tasks.new do |gem|
17
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
+ gem.name = "irs_forms"
19
+ gem.homepage = "http://github.com/ValencePM/irs_forms"
20
+ gem.license = "MIT"
21
+ gem.summary = %Q{Generate IRS forms with your data}
22
+ gem.description = %Q{Generate IRS forms with your data}
23
+ gem.email = "ryan@thewinograds.com"
24
+ gem.authors = ["Ryan Winograd"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "irs_forms #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/irs_forms.gemspec ADDED
@@ -0,0 +1,110 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "irs_forms"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Winograd"]
12
+ s.date = "2013-01-29"
13
+ s.description = "Generate IRS forms with your data"
14
+ s.email = "ryan@thewinograds.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "irs_forms.gemspec",
28
+ "lib/irs_forms.rb",
29
+ "lib/irs_forms/form.rb",
30
+ "lib/irs_forms/form1096.rb",
31
+ "lib/irs_forms/form1099.rb",
32
+ "lib/irs_forms/form1099_int.rb",
33
+ "lib/irs_forms/form1099_misc.rb",
34
+ "spec/assets/copyA_with_data_and_no_template.pdf-0.12.0.pdf",
35
+ "spec/assets/copyA_with_data_and_template.pdf-0.12.0.pdf",
36
+ "spec/assets/copyA_with_template.pdf-0.12.0.pdf",
37
+ "spec/assets/f1096_for_1099int.pdf-0.12.0.pdf",
38
+ "spec/assets/f1096_with_data_and_no_template.pdf-0.12.0.pdf",
39
+ "spec/assets/f1096_with_data_and_template.pdf-0.12.0.pdf",
40
+ "spec/assets/f1096_with_data_and_template_offset.pdf-0.12.0.pdf",
41
+ "spec/assets/f1096_with_template.pdf-0.12.0.pdf",
42
+ "spec/assets/f1099intA_data_and_template.pdf-0.12.0.pdf",
43
+ "spec/assets/f1099intA_data_and_template_offset.pdf-0.12.0.pdf",
44
+ "spec/assets/f1099intB_data_and_template.pdf-0.12.0.pdf",
45
+ "spec/assets/f1099intC_data_and_template.pdf-0.12.0.pdf",
46
+ "spec/assets/f1099msc1_data_and_template.pdf-0.12.0.pdf",
47
+ "spec/assets/f1099msc2_data_and_template.pdf-0.12.0.pdf",
48
+ "spec/assets/f1099mscA_data_and_template.pdf-0.12.0.pdf",
49
+ "spec/assets/f1099mscA_data_and_template_offset.pdf-0.12.0.pdf",
50
+ "spec/assets/f1099mscB_data_and_template.pdf-0.12.0.pdf",
51
+ "spec/assets/f1099mscC_data_and_template.pdf-0.12.0.pdf",
52
+ "spec/form1096_spec.rb",
53
+ "spec/form1099_int_spec.rb",
54
+ "spec/form1099_misc_spec.rb",
55
+ "spec/irs_forms_spec.rb",
56
+ "spec/spec_helper.rb",
57
+ "templates/NOTES",
58
+ "templates/f1096--2012.pdf",
59
+ "templates/f1096.pdf",
60
+ "templates/f1099int--2012.pdf",
61
+ "templates/f1099int-copyA.pdf",
62
+ "templates/f1099int-copyB.pdf",
63
+ "templates/f1099int-copyC.pdf",
64
+ "templates/f1099msc--2012.pdf",
65
+ "templates/f1099msc-copy1.pdf",
66
+ "templates/f1099msc-copy2.pdf",
67
+ "templates/f1099msc-copyA.pdf",
68
+ "templates/f1099msc-copyB.pdf",
69
+ "templates/f1099msc-copyC.pdf"
70
+ ]
71
+ s.homepage = "http://github.com/ValencePM/irs_forms"
72
+ s.licenses = ["MIT"]
73
+ s.require_paths = ["lib"]
74
+ s.rubygems_version = "1.8.10"
75
+ s.summary = "Generate IRS forms with your data"
76
+
77
+ if s.respond_to? :specification_version then
78
+ s.specification_version = 3
79
+
80
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
82
+ s.add_runtime_dependency(%q<prawn>, [">= 0.12.0"])
83
+ s.add_development_dependency(%q<rake>, [">= 0"])
84
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
85
+ s.add_development_dependency(%q<appraisal>, [">= 0"])
86
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
87
+ s.add_development_dependency(%q<rdoc>, [">= 3.12"])
88
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
89
+ else
90
+ s.add_dependency(%q<activesupport>, [">= 0"])
91
+ s.add_dependency(%q<prawn>, [">= 0.12.0"])
92
+ s.add_dependency(%q<rake>, [">= 0"])
93
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
94
+ s.add_dependency(%q<appraisal>, [">= 0"])
95
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
96
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
97
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
98
+ end
99
+ else
100
+ s.add_dependency(%q<activesupport>, [">= 0"])
101
+ s.add_dependency(%q<prawn>, [">= 0.12.0"])
102
+ s.add_dependency(%q<rake>, [">= 0"])
103
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
104
+ s.add_dependency(%q<appraisal>, [">= 0"])
105
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
106
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
107
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
108
+ end
109
+ end
110
+
@@ -0,0 +1,57 @@
1
+ class IrsForms::Form
2
+
3
+ attr_accessor :data, :x_offset, :y_offset
4
+
5
+ def initialize(options={})
6
+ self.data = options[:data] || {}
7
+ self.x_offset = options[:x_offset]
8
+ self.y_offset = options[:y_offset]
9
+ end
10
+
11
+ def template_filepath(filename)
12
+ dir = File.expand_path(File.dirname(__FILE__) + '/../../templates')
13
+ "#{dir}/#{filename}"
14
+ end
15
+
16
+ def to_pdf(options={})
17
+ to_prawn(options).render
18
+ end
19
+
20
+ def x_offset
21
+ @x_offset || 0
22
+ end
23
+
24
+ def y_offset
25
+ @y_offset || 0
26
+ end
27
+
28
+ private
29
+
30
+ def pdf_top
31
+ @pdf.bounds.top + y_offset
32
+ end
33
+
34
+ def pdf_left
35
+ @pdf.bounds.left + x_offset
36
+ end
37
+
38
+ def format_amount(string)
39
+ number = "%#.2f" % string.to_f
40
+
41
+ parts = number.to_s.to_str.split('.')
42
+ # Add comma delimeter for every three digits
43
+ # Taken from Rails' ActionView::Helpers::NumberHelper#number_with_delimeter
44
+ parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
45
+
46
+ parts.join('.').html_safe
47
+ end
48
+
49
+ def text(string, options={})
50
+ if options[:at]
51
+ @pdf.draw_text string.to_s, options
52
+ else
53
+ @pdf.text string.to_s, options
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,89 @@
1
+ class IrsForms::Form1096 < IrsForms::Form
2
+
3
+ def template_filepath
4
+ super("f1096.pdf")
5
+ end
6
+
7
+ def to_prawn(options={})
8
+ options.reverse_merge!(with_template: false)
9
+
10
+ prawn_options = {:bottom_margin => 0.0}
11
+ prawn_options.merge!(:template => template_filepath) if options[:with_template]
12
+
13
+ @pdf = Prawn::Document.new(prawn_options)
14
+ render_data_to_prawn
15
+ @pdf
16
+ end
17
+
18
+ private
19
+
20
+ def render_data_to_prawn
21
+ y_offset = 70
22
+ x_offset = 20
23
+
24
+ col2_offset = 200
25
+ col3_offset = 355
26
+
27
+ x = pdf_left + x_offset
28
+ y = pdf_top - y_offset - 10
29
+
30
+ # Filer Name/Address
31
+ @pdf.bounding_box([x + 20, y], :width => 260, :height => 75) do
32
+ text data[:filer_name].to_s
33
+ @pdf.move_down(20)
34
+ text data[:filer_street_address].to_s
35
+ @pdf.move_down(15)
36
+ text data[:filer_city_state_zip].to_s
37
+ end
38
+
39
+ y -= 86
40
+
41
+ # Person Contact Information
42
+ @pdf.bounding_box([x, y], :width => 200) do
43
+ text data[:contact_name].to_s
44
+ @pdf.move_down(10)
45
+ text data[:email_address].to_s
46
+ end
47
+ @pdf.bounding_box([x + col2_offset, y], :width => 200) do
48
+ text data[:telephone_number].to_s
49
+ @pdf.move_down(10)
50
+ text data[:fax_number].to_s
51
+ end
52
+
53
+ y -= 50
54
+
55
+ # EIN
56
+ @pdf.bounding_box([x, y], :width => 200) do
57
+ text data[:employer_identification_number].to_s
58
+ end
59
+
60
+ # SSN
61
+ @pdf.bounding_box([x + 100, y], :width => 200) do
62
+ text data[:social_security_number].to_s
63
+ end
64
+
65
+ # Total Number of Forms
66
+ @pdf.bounding_box([x + col2_offset, y], :width => 200) do
67
+ text data[:total_number_of_forms].to_s
68
+ end
69
+
70
+ # Total Amount Reported
71
+ @pdf.bounding_box([x + col2_offset + 190, y], :width => 200) do
72
+ text format_amount(data[:total_amount_reported]).to_s
73
+ end if data[:total_amount_reported]
74
+
75
+ row1 = 475 + self.y_offset
76
+ row2 = 428 + self.y_offset
77
+ col3 = 100 + self.x_offset
78
+ col14 = 515 + self.x_offset
79
+
80
+ check_form_coords = case data[:type_of_form]
81
+ when '1099int'
82
+ [col14, row1]
83
+ when '1099msc'
84
+ [col3, row2]
85
+ end
86
+ text "X", at: check_form_coords if check_form_coords
87
+ end
88
+
89
+ end
@@ -0,0 +1,47 @@
1
+ # Base class for Form1099s
2
+ class IrsForms::Form1099 < IrsForms::Form
3
+
4
+ attr_accessor :copy
5
+
6
+ COPIES = %W{A B C 1 2}
7
+
8
+ def initialize(options={})
9
+ options[:data] ||= []
10
+ super
11
+
12
+ self.copy = options[:copy]
13
+ check_valid_copy! if copy.present?
14
+ end
15
+
16
+ def to_prawn(options={})
17
+ options.reverse_merge!(with_template: false)
18
+
19
+ prawn_options = {:bottom_margin => 0.0}
20
+ prawn_options.merge!(:template => template_filepath) if options[:with_template]
21
+
22
+ @pdf = Prawn::Document.new(prawn_options)
23
+
24
+ data.each_with_index do |hash, index|
25
+ position = calculate_position(index)
26
+ @pdf.start_new_page(prawn_options) if index > 0 and position == :top
27
+ render_data_to_prawn(hash, position)
28
+ end
29
+
30
+ @pdf
31
+ end
32
+
33
+ private
34
+
35
+ def calculate_position(index)
36
+ raise 'Implement #calculate_position'
37
+ end
38
+
39
+ def render_data_to_prawn(hash, position)
40
+ raise 'Implement #render_data_to_prawn'
41
+ end
42
+
43
+ def check_valid_copy!
44
+ raise "Invalid copy. Must be one of #{COPIES}. You entered #{copy}." unless COPIES.include?(copy)
45
+ end
46
+
47
+ end
@@ -0,0 +1,87 @@
1
+ class IrsForms::Form1099Int < IrsForms::Form1099
2
+
3
+ COPIES = %W{A B C}
4
+
5
+ def template_filepath
6
+ super("f1099int-copy#{copy}.pdf")
7
+ end
8
+
9
+ private
10
+
11
+ def calculate_position(index)
12
+ case index%3
13
+ when 0
14
+ :top
15
+ when 1
16
+ :middle
17
+ when 2
18
+ :bottom
19
+ end
20
+ end
21
+
22
+ def render_data_to_prawn(hash, position)
23
+ y_offset = case position
24
+ when :top
25
+ 0
26
+ when :middle
27
+ 263
28
+ when :bottom
29
+ 528
30
+ end
31
+ x_offset = 20
32
+
33
+ col2_offset = 122
34
+ col3_offset = 255
35
+
36
+ x = pdf_left + x_offset
37
+ y = pdf_top - y_offset - 10
38
+
39
+ # Payer Contact Information
40
+ @pdf.bounding_box([x, y], :width => 240, :height => 90) do
41
+ hash[:payer_contact_information].each do |string|
42
+ text string
43
+ end
44
+ end
45
+
46
+ # Interest Income
47
+ @pdf.bounding_box([x + col3_offset, y - 25], :width => 120, :height => 50) do
48
+ text format_amount(hash[:interest_income])
49
+ end
50
+
51
+ y -= 75
52
+
53
+ # Payer Federal ID
54
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
55
+ text hash[:payer_federal_id]
56
+ end
57
+
58
+ # Recipient Federal ID
59
+ @pdf.bounding_box([x + col2_offset, y], :width => 120, :height => 50) do
60
+ text hash[:recipient_federal_id]
61
+ end
62
+
63
+ y -= 25
64
+
65
+ # Recipient Name
66
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
67
+ text hash[:recipient_name]
68
+ end
69
+
70
+ y -= 33
71
+
72
+ # Recipient Address
73
+ @pdf.bounding_box([x, y], :width => 240, :height => 50) do
74
+ text hash[:recipient_street_address]
75
+ @pdf.move_down 10
76
+ text hash[:recipient_city_state_zip]
77
+ end
78
+
79
+ y -= 50
80
+
81
+ # Recipient Account Number
82
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
83
+ text hash[:recipient_account_number]
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,77 @@
1
+ class IrsForms::Form1099Misc < IrsForms::Form1099
2
+
3
+ COPIES = %W{A B C 1 2}
4
+
5
+ def template_filepath
6
+ super("f1099msc-copy#{copy}.pdf")
7
+ end
8
+
9
+ private
10
+
11
+ def calculate_position(index)
12
+ index%2 == 0 ? :top : :bottom
13
+ end
14
+
15
+ def render_data_to_prawn(hash, position)
16
+ y_offset = (position == :top ? 0 : 395)
17
+ x_offset = 20
18
+
19
+ col2_offset = 122
20
+ col3_offset = 255
21
+
22
+ x = pdf_left + x_offset
23
+ y = pdf_top - y_offset - 10
24
+
25
+ # Payer Contact Information
26
+ @pdf.bounding_box([x, y], :width => 240, :height => 90) do
27
+ hash[:payer_contact_information].each do |string|
28
+ text string
29
+ end
30
+ end
31
+
32
+ y -= 115
33
+
34
+ # Payer Federal ID
35
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
36
+ text hash[:payer_federal_id]
37
+ end
38
+
39
+ # Recipient Federal ID
40
+ @pdf.bounding_box([x + col2_offset, y], :width => 120, :height => 50) do
41
+ text hash[:recipient_federal_id]
42
+ end
43
+
44
+ y -= 45
45
+
46
+ # Recipient Name
47
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
48
+ text hash[:recipient_name]
49
+ end
50
+
51
+ # Nonemployee compensation
52
+ @pdf.bounding_box([x + col3_offset, y - 10], :width => 120, :height => 50) do
53
+ text format_amount(hash[:nonemployee_compensation])
54
+ end
55
+
56
+ y -= 40
57
+
58
+ # Recipient Address
59
+ @pdf.bounding_box([x, y], :width => 240, :height => 50) do
60
+ text hash[:recipient_street_address]
61
+ @pdf.move_down 15
62
+ text hash[:recipient_city_state_zip]
63
+ end
64
+
65
+ y -= 60
66
+ # Recipient Account Number
67
+ @pdf.bounding_box([x, y], :width => 120, :height => 50) do
68
+ text hash[:recipient_account_number]
69
+ end
70
+
71
+ end
72
+
73
+ def check_valid_copy!
74
+ raise "Invalid copy. Must be one of #{COPIES}. You entered #{copy}." unless COPIES.include?(copy)
75
+ end
76
+
77
+ end
data/lib/irs_forms.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'prawn'
2
+ require 'prawn/layout' # only needed for versions <= 0.6.3
3
+ require 'active_support/all'
4
+
5
+ module IrsForms
6
+ end
7
+
8
+ dir = File.dirname(__FILE__) + '/irs_forms'
9
+ require "#{dir}/form"
10
+ require "#{dir}/form1099"
11
+ require "#{dir}/form1099_misc"
12
+ require "#{dir}/form1099_int"
13
+ require "#{dir}/form1096"