payday 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93a7b9df8926467ff4ef1b74328bcb3ee3b5415f
4
- data.tar.gz: 1b8798db48db996c6361f1710d79a5635ee5ca19
3
+ metadata.gz: 6880a9809ee7df8e384b8decd0496858eb7ebb32
4
+ data.tar.gz: 51bf1bb2e4c33baef16308e4f85b9f2915579d00
5
5
  SHA512:
6
- metadata.gz: 8ab5469683b247667df125a97f2b066c41f0058623976ec96c746bcf7d614cf16385a9244876c8d24b4e2e0605014c5d045a785cd89a48c8a9cab39e126755d3
7
- data.tar.gz: eed2f8315b300d9483012de8e399187c75a74caf55617f401f9d20d3a83ee13cb4294a9aed6c10491e529826f4e47e64698eb1e6543aa1ff006c7f26ae86f41e
6
+ metadata.gz: 22077148a2506af490538950d278c8afc1bdc755faac7b02e0cf449bab1824481006be542b41b3e6992fb0f651759d7752fd10ea4101c042c75955d2fa264d48
7
+ data.tar.gz: 5440e42e22b128aef4109c6986e15d73d993562c35df550431864c188fdfb1f9fbe8b9cc6868d749170197b9dc93a8329969b01346d85f8d7e11760be8dfdeb2
data/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ *.pdf binary
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.1
1
+ 2.1.5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.3 (2015-01-02)
4
+
5
+ * Loosened requirements on Money gem.
6
+ * Bumped rspec to latest and cleared up a deprecation warning.
7
+ * Added support for `invoice_date` field (thanks [danielma](https://github.com/danielma)!)
8
+ * Bugfix: Resolved issue where money values were being shown at 1/100th of the intended amount (thanks [watsonbox](https://github.com/watsonbox)!)
9
+
3
10
  ## 1.1.2 (2014-05-03)
4
11
 
5
12
  * Added NL locale (thanks [jedi4ever](https://github.com/jedi4ever)!).
@@ -5,7 +5,7 @@ module Payday
5
5
  include Payday::Invoiceable
6
6
 
7
7
  attr_accessor :invoice_number, :bill_to, :ship_to, :notes, :line_items, :shipping_rate, :shipping_description,
8
- :tax_rate, :tax_description, :due_at, :paid_at, :refunded_at, :currency, :invoice_details
8
+ :tax_rate, :tax_description, :due_at, :paid_at, :refunded_at, :currency, :invoice_details, :invoice_date
9
9
 
10
10
  def initialize(options = {})
11
11
  self.invoice_number = options[:invoice_number] || nil
@@ -22,6 +22,7 @@ module Payday
22
22
  self.refunded_at = options[:refunded_at] || nil
23
23
  self.currency = options[:currency] || nil
24
24
  self.invoice_details = options[:invoice_details] || []
25
+ self.invoice_date = options[:invoice_date] || nil
25
26
  end
26
27
 
27
28
  # The tax rate that we're applying, as a BigDecimal
@@ -126,6 +126,18 @@ module Payday
126
126
  table_data << [bold_cell(pdf, I18n.t('payday.invoice.invoice_no', :default => "Invoice #:")),
127
127
  bold_cell(pdf, invoice.invoice_number.to_s, :align => :right)]
128
128
  end
129
+
130
+ # invoice date
131
+ if defined?(invoice.invoice_date) && invoice.invoice_date
132
+ if invoice.invoice_date.is_a?(Date) || invoice.invoice_date.is_a?(Time)
133
+ invoice_date = invoice.invoice_date.strftime(Payday::Config.default.date_format)
134
+ else
135
+ invoice_date = invoice.invoice_date.to_s
136
+ end
137
+
138
+ table_data << [bold_cell(pdf, I18n.t('payday.invoice.invoice_date', :default => "Invoice Date:")),
139
+ bold_cell(pdf, invoice_date, :align => :right)]
140
+ end
129
141
 
130
142
  # Due on
131
143
  if defined?(invoice.due_at) && invoice.due_at
@@ -262,7 +274,10 @@ module Payday
262
274
 
263
275
  # Converts this number to a formatted currency string
264
276
  def self.number_to_currency(number, invoice)
265
- Money.new(number, invoice_or_default(invoice, :currency)).format
277
+ currency = Money::Currency.wrap(invoice_or_default(invoice, :currency))
278
+ number = number * currency.subunit_to_unit
279
+ number = number.round unless Money.infinite_precision
280
+ Money.new(number, currency).format
266
281
  end
267
282
 
268
283
  def self.max_cell_width(cell_proxy)
@@ -2,5 +2,5 @@
2
2
  module Payday
3
3
 
4
4
  # Current Version
5
- VERSION = "1.1.2"
5
+ VERSION = "1.1.3"
6
6
  end
data/payday.gemspec CHANGED
@@ -13,11 +13,11 @@ 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", "~> 1.0.0")
16
- s.add_dependency("money", "~> 6.1.1")
16
+ s.add_dependency("money", "~> 6.1")
17
17
  s.add_dependency("prawn-svg", "~> 0.15.0.0")
18
18
  s.add_dependency("i18n", ">= 0.6.9")
19
19
 
20
- s.add_development_dependency("rspec", "~> 2.14.1")
20
+ s.add_development_dependency("rspec", "~> 3.1.0")
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/spec/assets/svg.pdf CHANGED
Binary file
Binary file
data/spec/invoice_spec.rb CHANGED
@@ -8,7 +8,8 @@ module Payday
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
- :tax_rate => 0.125, :tax_description => "Local Sales Tax, 12.5%")
11
+ :tax_rate => 0.125, :tax_description => "Local Sales Tax, 12.5%",
12
+ :invoice_date => Date.civil(1993, 4, 12))
12
13
 
13
14
  expect(i.invoice_number).to eq(20)
14
15
  expect(i.bill_to).to eq("Here")
@@ -19,6 +20,7 @@ module Payday
19
20
  expect(i.shipping_description).to eq("USPS Priority Mail:")
20
21
  expect(i.tax_rate).to eq(BigDecimal.new("0.125"))
21
22
  expect(i.tax_description).to eq("Local Sales Tax, 12.5%")
23
+ expect(i.invoice_date).to eq(Date.civil(1993, 4, 12))
22
24
  end
23
25
 
24
26
  it "should total all of the line items into a subtotal correctly" do
@@ -182,6 +184,7 @@ module Payday
182
184
  :tax_rate => 0.1,
183
185
  :notes => "These are some crazy awesome notes!",
184
186
  :invoice_number => 12,
187
+ :invoice_date => Date.civil(2011, 1, 1),
185
188
  :due_at => Date.civil(2011, 1, 22),
186
189
  :bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
187
190
  :ship_to => "Frank Johnson\n101 That Way\nOther, SC 22229"
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ module Payday
4
+ describe PdfRenderer do
5
+ describe ".number_to_currency" do
6
+ it "formats numbers to currency currectly" do
7
+ expect(PdfRenderer.number_to_currency(20, nil)).to eq("$20.00")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -16,7 +16,7 @@ RSpec::Matchers.define(:match_binary_asset) do |file_name|
16
16
  end
17
17
  end
18
18
 
19
- failure_message_for_should do |actual_output|
19
+ failure_message do |actual_output|
20
20
  expected_output_path = File.join('spec/assets', file_name)
21
21
  actual_output_path = File.join('tmp/rendered_output', file_name)
22
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-03 00:00:00.000000000 Z
11
+ date: 2015-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.1.1
33
+ version: '6.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.1.1
40
+ version: '6.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: prawn-svg
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.14.1
75
+ version: 3.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.14.1
82
+ version: 3.1.0
83
83
  description: Payday is a library for rendering invoices. At present it supports rendering
84
84
  invoices to pdfs, but we're planning on adding support for other formats in the
85
85
  near future.
@@ -89,6 +89,7 @@ executables: []
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".gitattributes"
92
93
  - ".gitignore"
93
94
  - ".ruby-version"
94
95
  - CHANGELOG.md
@@ -122,6 +123,7 @@ files:
122
123
  - spec/assets/tiger.svg
123
124
  - spec/invoice_spec.rb
124
125
  - spec/line_item_spec.rb
126
+ - spec/pdf_renderer_spec.rb
125
127
  - spec/spec_helper.rb
126
128
  - spec/support/asset_matchers.rb
127
129
  homepage: ''
@@ -154,6 +156,7 @@ test_files:
154
156
  - spec/assets/tiger.svg
155
157
  - spec/invoice_spec.rb
156
158
  - spec/line_item_spec.rb
159
+ - spec/pdf_renderer_spec.rb
157
160
  - spec/spec_helper.rb
158
161
  - spec/support/asset_matchers.rb
159
162
  has_rdoc: