payday 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -2
- data/Gemfile +0 -2
- data/README.md +10 -7
- data/lib/generators/payday/setup/templates/migration.rb +1 -1
- data/lib/payday.rb +8 -8
- data/lib/payday/config.rb +2 -1
- data/lib/payday/i18n.rb +2 -1
- data/lib/payday/invoice.rb +2 -1
- data/lib/payday/invoiceable.rb +8 -3
- data/lib/payday/locale/de.yml +4 -3
- data/lib/payday/locale/en.yml +1 -0
- data/lib/payday/locale/es.yml +1 -0
- data/lib/payday/locale/nl.yml +22 -0
- data/lib/payday/pdf_renderer.rb +17 -4
- data/lib/payday/version.rb +1 -1
- data/payday.gemspec +5 -5
- data/{assets → spec/assets}/default_logo.png +0 -0
- data/spec/assets/svg.pdf +2360 -0
- data/spec/assets/testing.pdf +13988 -0
- data/{assets → spec/assets}/tiger.svg +0 -0
- data/spec/invoice_spec.rb +55 -38
- data/spec/spec_helper.rb +4 -5
- data/spec/support/asset_matchers.rb +25 -0
- metadata +42 -49
File without changes
|
data/spec/invoice_spec.rb
CHANGED
@@ -62,7 +62,7 @@ module Payday
|
|
62
62
|
# $1000 in Hats
|
63
63
|
i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
|
64
64
|
|
65
|
-
expect(i.total).to eq(BigDecimal.new("
|
65
|
+
expect(i.total).to eq(BigDecimal.new("1243"))
|
66
66
|
end
|
67
67
|
|
68
68
|
it "is overdue when it's past date and unpaid" do
|
@@ -80,6 +80,16 @@ module Payday
|
|
80
80
|
expect(i.overdue?).to eq(true)
|
81
81
|
end
|
82
82
|
|
83
|
+
it "shouldn't be refunded when not marked refunded" do
|
84
|
+
i = Invoice.new
|
85
|
+
expect(i.refunded?).not_to eq(true)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should be refunded when marked as refunded" do
|
89
|
+
i = Invoice.new(:refunded_at => Date.today)
|
90
|
+
expect(i.refunded?).to eq(true)
|
91
|
+
end
|
92
|
+
|
83
93
|
it "shouldn't be paid when not marked paid" do
|
84
94
|
i = Invoice.new
|
85
95
|
expect(i.paid?).not_to eq(true)
|
@@ -120,57 +130,64 @@ module Payday
|
|
120
130
|
Config.default.reset
|
121
131
|
end
|
122
132
|
|
123
|
-
|
133
|
+
let(:invoice) { new_invoice(invoice_params) }
|
134
|
+
let(:invoice_params) { {} }
|
135
|
+
|
136
|
+
it "should render to a file" do
|
124
137
|
File.unlink("tmp/testing.pdf") if File.exists?("tmp/testing.pdf")
|
125
138
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
:invoice_details => {"Ordered By:" => "Alan Johnson", "Paid By:" => "Dude McDude"})
|
139
|
+
invoice.render_pdf_to_file("tmp/testing.pdf")
|
140
|
+
|
141
|
+
expect(File.exists?("tmp/testing.pdf")).to be true
|
142
|
+
end
|
131
143
|
|
132
|
-
|
144
|
+
context 'with some invoice details' do
|
145
|
+
let(:invoice_params) { {
|
146
|
+
:invoice_details => { "Ordered By:" => "Alan Johnson", "Paid By:" => "Dude McDude" }
|
147
|
+
} }
|
133
148
|
|
134
|
-
|
135
|
-
|
136
|
-
i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
|
137
|
-
i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
|
138
|
-
end
|
149
|
+
it "should render an invoice correctly" do
|
150
|
+
Payday::Config.default.company_details = "10 This Way\nManhattan, NY 10001\n800-111-2222\nawesome@awesomecorp.com"
|
139
151
|
|
140
|
-
|
152
|
+
invoice.line_items += [
|
153
|
+
LineItem.new(:price => 20, :quantity => 5, :description => "Pants"),
|
154
|
+
LineItem.new(:price => 10, :quantity => 3, :description => "Shirts"),
|
155
|
+
LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
|
156
|
+
] * 30
|
141
157
|
|
142
|
-
|
158
|
+
expect(invoice.render_pdf).to match_binary_asset 'testing.pdf'
|
159
|
+
end
|
143
160
|
end
|
144
161
|
|
145
|
-
|
146
|
-
|
147
|
-
:
|
148
|
-
:bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222", :ship_to => "Frank Johnson\n101 That Way\nOther, SC 22229")
|
149
|
-
|
150
|
-
3.times do
|
151
|
-
i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
|
152
|
-
i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
|
153
|
-
i.line_items << LineItem.new(:price => 5, :quantity => 200.0, :description => "Hats")
|
162
|
+
context 'paid, with an svg logo' do
|
163
|
+
before do
|
164
|
+
Payday::Config.default.invoice_logo = { :filename => "spec/assets/tiger.svg", :size => "100x100" }
|
154
165
|
end
|
155
166
|
|
156
|
-
|
157
|
-
end
|
167
|
+
let(:invoice_params) { { :paid_at => Date.civil(2012, 2, 22) } }
|
158
168
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
169
|
+
it 'should render an invoice correctly' do
|
170
|
+
invoice.line_items += [
|
171
|
+
LineItem.new(:price => 20, :quantity => 5, :description => "Pants"),
|
172
|
+
LineItem.new(:price => 10, :quantity => 3, :description => "Shirts"),
|
173
|
+
LineItem.new(:price => 5, :quantity => 200.0, :description => "Hats")
|
174
|
+
] * 3
|
164
175
|
|
165
|
-
|
166
|
-
i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
|
167
|
-
i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
|
168
|
-
i.line_items << LineItem.new(:price => 5, :quantity => 200.0, :description => "Hats")
|
176
|
+
expect(invoice.render_pdf).to match_binary_asset 'svg.pdf'
|
169
177
|
end
|
178
|
+
end
|
170
179
|
|
171
|
-
|
172
|
-
|
173
|
-
|
180
|
+
def new_invoice(params = {})
|
181
|
+
default_params = {
|
182
|
+
:tax_rate => 0.1,
|
183
|
+
:notes => "These are some crazy awesome notes!",
|
184
|
+
:invoice_number => 12,
|
185
|
+
:due_at => Date.civil(2011, 1, 22),
|
186
|
+
:bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
|
187
|
+
:ship_to => "Frank Johnson\n101 That Way\nOther, SC 22229"
|
188
|
+
}
|
189
|
+
|
190
|
+
Invoice.new(default_params.merge(params))
|
174
191
|
end
|
175
192
|
end
|
176
193
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'bundler/setup'
|
1
|
+
require_relative '../lib/payday'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
require
|
3
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
4
|
+
# spec/support/ and its subdirectories.
|
5
|
+
Dir["spec/support/**/*.rb"].each { |f| require f[5..-1] }
|
7
6
|
|
8
7
|
RSpec.configure do |config|
|
9
8
|
# some (optional) config here
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# Usage: expect(renderer.render).to match_binary_asset('pdf/test.pdf')
|
4
|
+
RSpec::Matchers.define(:match_binary_asset) do |file_name|
|
5
|
+
match do |actual_output|
|
6
|
+
expected_path = File.join('spec/assets', file_name)
|
7
|
+
expected_output = File.binread(expected_path)
|
8
|
+
|
9
|
+
(actual_output == expected_output).tap do |result|
|
10
|
+
unless result
|
11
|
+
output_path = File.join('tmp/rendered_output', file_name)
|
12
|
+
|
13
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
14
|
+
File.open(output_path, "wb") { |f| f.write actual_output }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_for_should do |actual_output|
|
20
|
+
expected_output_path = File.join('spec/assets', file_name)
|
21
|
+
actual_output_path = File.join('tmp/rendered_output', file_name)
|
22
|
+
|
23
|
+
"expected output to match '#{expected_output_path}' (see #{actual_output_path})"
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,96 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Alan Johnson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: prawn
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
19
|
+
version: 1.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
26
|
+
version: 1.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: money
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 6.1.1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: 6.1.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: prawn-svg
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
47
|
+
version: 0.15.0.0
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
54
|
+
version: 0.15.0.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: i18n
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
61
|
+
version: 0.6.9
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
68
|
+
version: 0.6.9
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
70
|
+
name: rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
75
|
+
version: 2.14.1
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
82
|
+
version: 2.14.1
|
94
83
|
description: Payday is a library for rendering invoices. At present it supports rendering
|
95
84
|
invoices to pdfs, but we're planning on adding support for other formats in the
|
96
85
|
near future.
|
@@ -100,13 +89,12 @@ executables: []
|
|
100
89
|
extensions: []
|
101
90
|
extra_rdoc_files: []
|
102
91
|
files:
|
103
|
-
- .gitignore
|
92
|
+
- ".gitignore"
|
93
|
+
- ".ruby-version"
|
104
94
|
- CHANGELOG.md
|
105
95
|
- Gemfile
|
106
96
|
- README.md
|
107
97
|
- Rakefile
|
108
|
-
- assets/default_logo.png
|
109
|
-
- assets/tiger.svg
|
110
98
|
- lib/generators/payday/setup/USAGE
|
111
99
|
- lib/generators/payday/setup/setup_generator.rb
|
112
100
|
- lib/generators/payday/setup/templates/invoice.rb
|
@@ -123,44 +111,49 @@ files:
|
|
123
111
|
- lib/payday/locale/en.yml
|
124
112
|
- lib/payday/locale/es.yml
|
125
113
|
- lib/payday/locale/fr.yml
|
114
|
+
- lib/payday/locale/nl.yml
|
126
115
|
- lib/payday/locale/zh-CN.yml
|
127
116
|
- lib/payday/pdf_renderer.rb
|
128
117
|
- lib/payday/version.rb
|
129
118
|
- payday.gemspec
|
119
|
+
- spec/assets/default_logo.png
|
120
|
+
- spec/assets/svg.pdf
|
121
|
+
- spec/assets/testing.pdf
|
122
|
+
- spec/assets/tiger.svg
|
130
123
|
- spec/invoice_spec.rb
|
131
124
|
- spec/line_item_spec.rb
|
132
125
|
- spec/spec_helper.rb
|
126
|
+
- spec/support/asset_matchers.rb
|
133
127
|
homepage: ''
|
134
128
|
licenses: []
|
129
|
+
metadata: {}
|
135
130
|
post_install_message:
|
136
131
|
rdoc_options: []
|
137
132
|
require_paths:
|
138
133
|
- lib
|
139
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
none: false
|
141
135
|
requirements:
|
142
|
-
- -
|
136
|
+
- - ">="
|
143
137
|
- !ruby/object:Gem::Version
|
144
138
|
version: '0'
|
145
|
-
segments:
|
146
|
-
- 0
|
147
|
-
hash: 2492971967055799217
|
148
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
140
|
requirements:
|
151
|
-
- -
|
141
|
+
- - ">="
|
152
142
|
- !ruby/object:Gem::Version
|
153
143
|
version: '0'
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
hash: 2492971967055799217
|
157
144
|
requirements: []
|
158
145
|
rubyforge_project:
|
159
|
-
rubygems_version:
|
146
|
+
rubygems_version: 2.2.2
|
160
147
|
signing_key:
|
161
|
-
specification_version:
|
148
|
+
specification_version: 4
|
162
149
|
summary: git remote add origin git@github.com:commondream/payday.git
|
163
150
|
test_files:
|
151
|
+
- spec/assets/default_logo.png
|
152
|
+
- spec/assets/svg.pdf
|
153
|
+
- spec/assets/testing.pdf
|
154
|
+
- spec/assets/tiger.svg
|
164
155
|
- spec/invoice_spec.rb
|
165
156
|
- spec/line_item_spec.rb
|
166
157
|
- spec/spec_helper.rb
|
158
|
+
- spec/support/asset_matchers.rb
|
159
|
+
has_rdoc:
|