payday 1.0.0beta4 → 1.0.0beta5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,7 +27,7 @@ Example:
27
27
 
28
28
  Documentation
29
29
  ===
30
- Documentation for the latest version of Payday is available at [rdoc.info](http://rdoc.info/github/commondream/payday/v1.0.0beta2/frames).
30
+ Documentation for the latest version of Payday is available at [rdoc.info](http://rdoc.info/github/commondream/payday/v1.0.0beta5/frames).
31
31
 
32
32
  Customizing Your Logo and Company Name
33
33
  ===
@@ -112,7 +112,7 @@ There's also an example Rails application running on Heroku at [http://payday-ex
112
112
 
113
113
  Contributing
114
114
  ===
115
- Payday is pretty young, so there's still a good bit of work to be done. Feel free to fork the project, make some changes, and send a pull request. If you're unsure about what to work on, send me a message on GitHub. I'd love the help!
115
+ Payday is pretty young, so there's still a good bit of work to be done. I highly recommend sending me a message on GitHub before making too many changes, just to make sure that two folks aren't doing the same work, but beyond that feel free to fork the project, make some changes, and send a pull request. If you're unsure about what to work on but would like to help, send me a message on GitHub. I'd love the help!
116
116
 
117
117
  To Do
118
118
  ===
@@ -122,7 +122,6 @@ Here's what we're planning on working on with Payday in the near future:
122
122
  * Release 1.0!
123
123
 
124
124
  * Actually get a designer to style the invoices.
125
- * Add support for currencies other than USD
126
125
  * Add support for Money gem or BigDecimal or general numerics (right now we support BigDecimal and general numerics)
127
126
  * Add support for blank line items
128
127
  * Add support for indented line items
Binary file
data/lib/payday.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'date'
3
3
  require 'bigdecimal'
4
4
  require 'prawn'
5
+ require 'money'
5
6
 
6
7
  require File.join(File.dirname(__FILE__), "payday", "version")
7
8
  require File.join(File.dirname(__FILE__), "payday", "config")
data/lib/payday/config.rb CHANGED
@@ -16,6 +16,7 @@ module Payday
16
16
  self.company_name = "Awesome Corp"
17
17
  self.company_details = "awesomecorp@commondream.net"
18
18
  self.date_format = "%B %e, %Y"
19
+ self.currency = "USD"
19
20
  end
20
21
  end
21
22
  end
@@ -54,12 +54,15 @@ module Payday
54
54
 
55
55
  def self.company_banner(invoice, pdf)
56
56
  # render the logo
57
- logo_info = pdf.image(invoice_or_default(invoice, :invoice_logo), :at => pdf.bounds.top_left, :fit => [200, 100])
57
+ logo_info = pdf.image(invoice_or_default(invoice, :invoice_logo), :at => pdf.bounds.top_left)
58
58
 
59
59
  # render the company details
60
+ company_details = invoice_or_default(invoice, :company_details)
61
+ company_details = company_details.lines.inject("") { |combined, line| combined << line.strip }
62
+
60
63
  table_data = []
61
- table_data << [bold_cell(pdf, invoice_or_default(invoice, :company_name), :size => 12)]
62
- table_data << [invoice_or_default(invoice, :company_details)]
64
+ table_data << [bold_cell(pdf, invoice_or_default(invoice, :company_name).strip, :size => 12)]
65
+ table_data << [company_details]
63
66
  table = pdf.make_table(table_data, :cell_style => { :borders => [], :padding => [2, 0] })
64
67
  pdf.bounding_box([pdf.bounds.width - table.width, pdf.bounds.top], :width => table.width, :height => table.height) do
65
68
  table.draw
@@ -136,8 +139,8 @@ module Payday
136
139
  bold_cell(pdf, "Quantity", :align => :center, :borders => []),
137
140
  bold_cell(pdf, "Amount", :align => :center, :borders => [])]
138
141
  invoice.line_items.each do |line|
139
- table_data << [line.description, number_to_currency(line.price), BigDecimal.new(line.quantity.to_s).to_s("F"),
140
- number_to_currency(line.amount)]
142
+ table_data << [line.description, number_to_currency(line.price, invoice), BigDecimal.new(line.quantity.to_s).to_s("F"),
143
+ number_to_currency(line.amount, invoice)]
141
144
  end
142
145
 
143
146
  pdf.move_cursor_to(pdf.cursor - 20)
@@ -156,10 +159,10 @@ module Payday
156
159
 
157
160
  def self.totals_lines(invoice, pdf)
158
161
  table_data = []
159
- table_data << [bold_cell(pdf, "Subtotal:"), cell(pdf, number_to_currency(invoice.subtotal), :align => :right)]
160
- table_data << [bold_cell(pdf, "Tax:"), cell(pdf, number_to_currency(invoice.tax), :align => :right)]
162
+ table_data << [bold_cell(pdf, "Subtotal:"), cell(pdf, number_to_currency(invoice.subtotal, invoice), :align => :right)]
163
+ table_data << [bold_cell(pdf, "Tax:"), cell(pdf, number_to_currency(invoice.tax, invoice), :align => :right)]
161
164
  table_data << [bold_cell(pdf, "Total:", :size => 12),
162
- cell(pdf, number_to_currency(invoice.total), :size => 12, :align => :right)]
165
+ cell(pdf, number_to_currency(invoice.total, invoice), :size => 12, :align => :right)]
163
166
  table = pdf.make_table(table_data, :cell_style => { :borders => [] })
164
167
  pdf.bounding_box([pdf.bounds.width - table.width, pdf.cursor], :width => table.width, :height => table.height + 2) do
165
168
  table.draw
@@ -202,8 +205,9 @@ module Payday
202
205
  number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
203
206
  end
204
207
 
205
- def self.number_to_currency(number)
206
- number_with_delimiter(sprintf("$%.02f", number))
208
+ # Converts this number to a formatted currency string
209
+ def self.number_to_currency(number, invoice)
210
+ number.to_money(invoice_or_default(invoice, :currency)).format
207
211
  end
208
212
 
209
213
  def self.max_cell_width(cell_proxy)
@@ -2,5 +2,5 @@
2
2
  module Payday
3
3
 
4
4
  # Current Version
5
- VERSION = "1.0.0beta4"
5
+ VERSION = "1.0.0beta5"
6
6
  end
data/payday.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{Payday is a library for rendering invoices. At present it supports rendering invoices to pdfs, but we're planning on adding support for other formats in the near future.}
14
14
 
15
15
  s.add_dependency("prawn", "~> 0.11.1.pre")
16
+ s.add_dependency("money", "~> 3.6.1")
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payday
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196363
4
+ hash: 62196361
5
5
  prerelease: 5
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 4
12
- version: 1.0.0beta4
11
+ - 5
12
+ version: 1.0.0beta5
13
13
  platform: ruby
14
14
  authors:
15
15
  - Alan Johnson
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-03-08 00:00:00 -05:00
20
+ date: 2011-03-09 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -37,6 +37,22 @@ dependencies:
37
37
  version: 0.11.1.pre
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: money
42
+ prerelease: false
43
+ requirement: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ hash: 29
49
+ segments:
50
+ - 3
51
+ - 6
52
+ - 1
53
+ version: 3.6.1
54
+ type: :runtime
55
+ version_requirements: *id002
40
56
  description: Payday is a library for rendering invoices. At present it supports rendering invoices to pdfs, but we're planning on adding support for other formats in the near future.
41
57
  email:
42
58
  - alan@commondream.net