payday 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+ gem "rake"
@@ -209,7 +209,7 @@ module Payday
209
209
 
210
210
  def self.page_numbers(pdf)
211
211
  if pdf.page_count > 1
212
- pdf.number_pages("<page> / <total>", [pdf.bounds.right - 18, -15])
212
+ pdf.number_pages("<page> / <total>", :at => [pdf.bounds.right - 18, -15])
213
213
  end
214
214
  end
215
215
 
@@ -2,5 +2,5 @@
2
2
  module Payday
3
3
 
4
4
  # Current Version
5
- VERSION = "1.0.4"
5
+ VERSION = "1.0.5"
6
6
  end
data/test/invoice_test.rb CHANGED
@@ -2,14 +2,14 @@ require File.expand_path("test/test_helper")
2
2
 
3
3
  module Payday
4
4
  class InvoiceTest < MiniTest::Unit::TestCase
5
-
5
+
6
6
  test "that setting values through the options hash on initialization works" do
7
7
  i = Invoice.new(:invoice_number => 20, :bill_to => "Here", :ship_to => "There",
8
8
  :notes => "These are some notes.",
9
9
  :line_items => [LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")],
10
10
  :shipping_rate => 15.00, :shipping_description => "USPS Priority Mail:",
11
11
  :tax_rate => 0.125, :tax_description => "Local Sales Tax, 12.5%")
12
-
12
+
13
13
  assert_equal 20, i.invoice_number
14
14
  assert_equal "Here", i.bill_to
15
15
  assert_equal "There", i.ship_to
@@ -20,123 +20,123 @@ module Payday
20
20
  assert_equal BigDecimal.new("0.125"), i.tax_rate
21
21
  assert_equal "Local Sales Tax, 12.5%", i.tax_description
22
22
  end
23
-
23
+
24
24
  test "that subtotal totals up all of the line items in an invoice correctly" do
25
25
  i = Invoice.new
26
-
26
+
27
27
  # $100 in Pants
28
28
  i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
29
-
29
+
30
30
  # $30 in Shirts
31
31
  i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
32
-
32
+
33
33
  # $1000 in Hats
34
34
  i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
35
-
35
+
36
36
  assert_equal BigDecimal.new("1130"), i.subtotal
37
37
  end
38
-
38
+
39
39
  test "that tax returns the correct tax amount, rounded to two decimal places" do
40
40
  i = Invoice.new(:tax_rate => 0.1)
41
41
  i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
42
-
42
+
43
43
  assert_equal(BigDecimal.new("10"), i.tax)
44
44
  end
45
-
45
+
46
46
  test "that taxes aren't applied to invoices with a subtotal of 0 or a negative amount" do
47
47
  i = Invoice.new(:tax_rate => 0.1)
48
48
  i.line_items << LineItem.new(:price => -1, :quantity => 100, :description => "Negative Priced Pants")
49
-
49
+
50
50
  assert_equal(BigDecimal.new("0"), i.tax)
51
51
  end
52
-
52
+
53
53
  test "that the total for this invoice calculates correctly" do
54
54
  i = Invoice.new(:tax_rate => 0.1)
55
-
55
+
56
56
  # $100 in Pants
57
57
  i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
58
-
58
+
59
59
  # $30 in Shirts
60
60
  i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
61
-
61
+
62
62
  # $1000 in Hats
63
63
  i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
64
-
64
+
65
65
  assert_equal BigDecimal.new("1243"), i.total
66
66
  end
67
-
67
+
68
68
  test "overdue? is false when past date and unpaid" do
69
69
  i = Invoice.new(:due_at => Date.today - 1)
70
70
  assert i.overdue?
71
71
  end
72
-
72
+
73
73
  test "overdue? is true when past date but paid" do
74
74
  i = Invoice.new(:due_at => Date.today - 1, :paid_at => Date.today)
75
75
  assert !i.overdue?
76
76
  end
77
-
77
+
78
78
  test "overdue? when due_at is a time" do
79
79
  i = Invoice.new(:due_at => Time.parse("Jan 1 14:33:20 GMT 2011"))
80
80
  assert i.overdue?
81
81
  end
82
-
82
+
83
83
  test "paid is false when not paid" do
84
84
  i = Invoice.new
85
85
  assert !i.paid?
86
86
  end
87
-
87
+
88
88
  test "paid is true when paid" do
89
89
  i = Invoice.new(:paid_at => Date.today)
90
90
  assert i.paid?
91
91
  end
92
-
92
+
93
93
  test "iterating through invoice_details as two element arrays" do
94
94
  i = Invoice.new(:invoice_details => [["Test", "Yes"], ["Awesome", "Absolutely"]])
95
95
  details = []
96
96
  i.each_detail do |key, value|
97
97
  details << [key, value]
98
98
  end
99
-
99
+
100
100
  assert_equal 2, details.length
101
101
  assert details.include?(["Test", "Yes"])
102
102
  assert details.include?(["Awesome", "Absolutely"])
103
103
  end
104
-
104
+
105
105
  test "iterating through invoice_details as a hash" do
106
106
  i = Invoice.new(:invoice_details => {"Test" => "Yes", "Awesome" => "Absolutely"})
107
107
  details = []
108
108
  i.each_detail do |key, value|
109
109
  details << [key, value]
110
110
  end
111
-
111
+
112
112
  assert_equal 2, details.length
113
113
  assert details.include?(["Test", "Yes"])
114
114
  assert details.include?(["Awesome", "Absolutely"])
115
115
  end
116
-
116
+
117
117
  test "rendering to file" do
118
118
  File.unlink("tmp/testing.pdf") if File.exists?("tmp/testing.pdf")
119
119
  assert !File.exists?("tmp/testing.pdf")
120
-
120
+
121
121
  i = Invoice.new(:tax_rate => 0.1, :notes => "These are some crazy awesome notes!", :invoice_number => 12,
122
122
  :due_at => Date.civil(2011, 1, 22), #:paid_at => Date.civil(2012, 2, 22),
123
- :bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
123
+ :bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
124
124
  :ship_to => "Frank Johnson\n101 That Way\nOther, SC 22229",
125
125
  :invoice_details => {"Ordered By:" => "Alan Johnson", "Paid By:" => "Dude McDude"})
126
-
126
+
127
127
  Payday::Config.default.company_details = "10 This Way\nManhattan, NY 10001\n800-111-2222\nawesome@awesomecorp.com"
128
-
129
- 3.times do
128
+
129
+ 30.times do
130
130
  i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
131
131
  i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
132
132
  i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
133
133
  end
134
134
 
135
135
  i.render_pdf_to_file("tmp/testing.pdf")
136
-
136
+
137
137
  assert File.exists?("tmp/testing.pdf")
138
138
  end
139
-
139
+
140
140
  test "rendering to string" do
141
141
  i = Invoice.new(:tax_rate => 0.1, :notes => "These are some crazy awesome notes!", :invoice_number => 12,
142
142
  :due_at => Date.civil(2011, 1, 22), :paid_at => Date.civil(2012, 2, 22),
@@ -151,4 +151,4 @@ module Payday
151
151
  refute_nil i.render_pdf
152
152
  end
153
153
  end
154
- end
154
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn
16
- requirement: &70204475070780 !ruby/object:Gem::Requirement
16
+ requirement: &70310126074000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.12.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70204475070780
24
+ version_requirements: *70310126074000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: money
27
- requirement: &70204475070280 !ruby/object:Gem::Requirement
27
+ requirement: &70310126073500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.6.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70204475070280
35
+ version_requirements: *70310126073500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: i18n
38
- requirement: &70204475069820 !ruby/object:Gem::Requirement
38
+ requirement: &70310126073000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.5.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70204475069820
46
+ version_requirements: *70310126073000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &70204475069380 !ruby/object:Gem::Requirement
49
+ requirement: &70310126072600 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70204475069380
57
+ version_requirements: *70310126072600
58
58
  description: Payday is a library for rendering invoices. At present it supports rendering
59
59
  invoices to pdfs, but we're planning on adding support for other formats in the
60
60
  near future.