receipts 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fead98b1a43ff6d6c86b13f9c8114ebcfa322b809f9f2b068b80e03370c63f65
4
- data.tar.gz: e7e29ceceac61563c182626d3d47ab697584e67896aff884097bb955236d44ca
3
+ metadata.gz: 875a1ff6a3a1dcca7a1de7c21362ce0837426c3f5b3299cd9f15f38daf97cfa2
4
+ data.tar.gz: 2aed77f22588a1675b558eccbe1122cc94912e04fa692aacaa7a40b16429495e
5
5
  SHA512:
6
- metadata.gz: de764a9d7466e6680243ac5b2f033534a6140048f99eb5bc15aaad5b38d27063e4ed7e70f2d45167064dec7b3f941d34b0cab29aab1977e876c926ded6e80839
7
- data.tar.gz: 7da1873655534b34d80bb735b8fe80da1d84d6f0618f1d1c7be35991e2d5ffeb197aa4b07390a3ba3aba4317ef42c7a874756b075213422d164ed296b9bb7a2b
6
+ metadata.gz: f54fc0957bccf87ebd1ae377d275f9dfe0f39a8b2cd0e8c4b5a96635183abd24f229eea142631a98d5a61156fc87cd366864e35a044a53e60ec072de08ada3e5
7
+ data.tar.gz: 87745a1fe2f9cb84c69a00d816e254c4cc7b2dfee02457ece89d9e543a39b65813bfd427e7fa789e5a56feea1a3837ac3e8cc5d4574e4894805b535de76cf630
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ### Unreleased
2
2
 
3
+ ### 2.0.0
4
+
5
+ * New, consistent layouts between Receipts, Invoices, and Statements - @excid3
6
+ * PDFs can now be completely customized - @excid3
7
+ * Add line_items to Receipts - @excid3
8
+
3
9
  ### 1.2.0
4
10
 
5
11
  * Update design to give more room for longer product names, addresses, etc - @excid3
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in receipts.gemspec
4
4
  gemspec
5
+
6
+ gem "minitest", "~> 5.0"
7
+ gem "rake", "~> 13.0"
8
+ gem "standard"
9
+ gem "matrix", "~> 0.4"
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ![travisci](https://api.travis-ci.org/excid3/receipts.svg)
2
2
 
3
- # Receipts
3
+ # Receipts Gem
4
4
 
5
- Receipts for your Rails application that works with any payment provider.
5
+ Receipts, Invoices, and Statements for your Rails application that works with any payment provider. Receipts uses Prawn to generate the PDFs.
6
6
 
7
- Check out the [example receipt](https://github.com/excid3/receipts/blob/master/examples/receipt.pdf?raw=true) and [example invoice](https://github.com/excid3/receipts/blob/master/examples/invoice.pdf?raw=true) PDFs.
7
+ Check out the [example PDFs](https://github.com/excid3/receipts/blob/master/examples/).
8
8
 
9
9
  ## Installation
10
10
 
@@ -24,112 +24,99 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- Adding receipts to your application is pretty simple. All you need is a
28
- model that stores your transaction details. In this example our
29
- application has a model named `Charge` that we will use.
30
-
31
- We're going to add a method called `receipt` on our model called `Charge`
32
- that will create a new receipt for the charge using attributes from the
33
- model.
34
-
35
- Video Tutorial:
36
- [GoRails Episode #51](https://gorails.com/episodes/pdf-receipts)
27
+ To generate a Receipt, Invoice, or Statement, create an instance and provide content to render:
37
28
 
38
29
  ```ruby
39
- # == Schema Information
40
- #
41
- # Table name: charges
42
- #
43
- # id :integer not null, primary key
44
- # user_id :integer
45
- # stripe_id :string(255)
46
- # amount :integer
47
- # card_last4 :string(255)
48
- # card_type :string(255)
49
- # card_exp_month :integer
50
- # card_exp_year :integer
51
- # uuid :string
52
- # created_at :datetime
53
- # updated_at :datetime
54
- #
55
-
56
- class Charge < ActiveRecord::Base
57
- belongs_to :user
58
- validates :stripe_id, uniqueness: true
59
-
60
- def receipt
61
- Receipts::Receipt.new(
62
- id: id,
63
- subheading: "RECEIPT FOR CHARGE #%{id}",
64
- product: "GoRails",
65
- company: {
66
- name: "GoRails, LLC.",
67
- address: "123 Fake Street\nNew York City, NY 10012",
68
- email: "support@example.com",
69
- logo: Rails.root.join("app/assets/images/logo.png")
70
- },
71
- line_items: [
72
- ["Date", created_at.to_s],
73
- ["Account Billed", "#{user.name} (#{user.email})"],
74
- ["Product", "GoRails"],
75
- ["Amount", "$#{amount / 100}.00"],
76
- ["Charged to", "#{card_type} (**** **** **** #{card_last4})"],
77
- ["Transaction ID", uuid]
78
- ],
79
- font: {
80
- bold: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic-Bold.ttf'),
81
- normal: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic.ttf'),
82
- }
83
- )
84
- end
85
- end
30
+ r = Receipts::Receipt.new(
31
+ details: [
32
+ ["Receipt Number", "123"],
33
+ ["Date paid", Date.today],
34
+ ["Payment method", "ACH super long super long super long super long super long"]
35
+ ],
36
+ company: {
37
+ name: "Example, LLC",
38
+ address: "123 Fake Street\nNew York City, NY 10012",
39
+ email: "support@example.com",
40
+ logo: File.expand_path("./examples/images/logo.png")
41
+ },
42
+ recipient: [
43
+ "Customer",
44
+ "Their Address",
45
+ "City, State Zipcode",
46
+ nil,
47
+ "customer@example.org"
48
+ ],
49
+ line_items: [
50
+ ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
51
+ ["Subscription", "$19.00", "1", "$19.00"],
52
+ [nil, nil, "Subtotal", "$19.00"],
53
+ [nil, nil, "Tax", "$1.12"],
54
+ [nil, nil, "Total", "$20.12"],
55
+ [nil, nil, "<b>Amount paid</b>", "$20.12"],
56
+ [nil, nil, "Refunded on #{Date.today}", "$5.00"]
57
+ ],
58
+ footer: "Thanks for your business. Please contact us if you have any questions."
59
+ )
60
+
61
+ # Returns a string of the raw PDF
62
+ r.render
63
+
64
+ # Writes the PDF to disk
65
+ r.render_file "examples/receipt.pdf"
86
66
  ```
87
67
 
88
- Update the options for the receipt according to the data you want to
89
- display.
68
+ ### Options
90
69
 
91
- ## Customizing Your Receipts
70
+ You can pass the following options to generate a PDF:
92
71
 
93
- * `id` - **Required**
72
+ * `recipient` - Array of customer details to include. Typically, this is name, address, email, VAT ID, etc.
94
73
 
95
- This sets the ID of the charge on the receipt
74
+ * `company` - Hash of your company details
96
75
 
97
- * `product` or `message` - **Required**
76
+ * `name` - Company name
98
77
 
99
- You can set either the product or message options. If you set product, it will use the default message. If you want a custom message, you can set the message option to populate it with custom text.
78
+ * `address` - Company address
100
79
 
101
- * `company` - **Required**
80
+ * `email` - Company support email address
102
81
 
103
- Company consists of several required nested attributes.
82
+ * `phone` - Company phone number - _Optional_
104
83
 
105
- * `name` - **Required**
106
- * `address` - **Required**
107
- * `email` - **Required**
108
- * `line_items` - **Required**
84
+ * `logo` - Logo to be displayed on the receipt - _Optional_
85
+ This can be either a Path, File, StringIO, or URL. Here are a few examples:
109
86
 
110
- You can set as many line items on the receipts as you want. Just pass in an array with each item containing a name and a value to display on the receipt.
87
+ ```ruby
88
+ logo: Rails.root.join("app/assets/images/logo.png")
89
+ logo: File.expand_path("./logo.png")
90
+ logo: File.open("app/assets/images/logo.png", "rb")
91
+ logo: "https://www.ruby-lang.org/images/header-ruby-logo@2x.png" # Downloaded with OpenURI
92
+ ```
111
93
 
112
- * `logo` - *Optional*
94
+ * `details` - Array of details about the Receipt, Invoice, Statement. Typically, this is receipt numbers, issue date, due date, status, etc.
113
95
 
114
- The logo must be either a string path to a file or a file-like object.
96
+ * `line_items` - Array of line items to be displayed in table format.
115
97
 
116
- ```ruby
117
- logo: Rails.root.join("app/assets/images/logo.png")
118
- # or
119
- logo: File.open("app/assets/images/logo.png", "rb")
120
- ```
98
+ * `footer` - String for a message at the bottom of the PDF.
121
99
 
122
- To use an image from a URL, we recommend using `open-uri` to open the remote file as a StringIO object.
100
+ * `font` - Hash of paths to font files - _Optional_
123
101
 
124
- `require 'open-uri'`
102
+ ```ruby
103
+ font: {
104
+ bold: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic-Bold.ttf'),
105
+ normal: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic.ttf'),
106
+ }
107
+ ```
125
108
 
126
- `logo: URI.open("https://www.ruby-lang.org/images/header-ruby-logo@2x.png")`
109
+ Here's an example of where each option is displayed.
127
110
 
128
- * `font` - *Optional*
111
+ ![options](examples/images/options.jpg)
129
112
 
130
- If you'd like to use your own custom font, you can pass in the file paths to the `normal` and `bold` variations of your font. The bold font variation is required because it is used in the default message. If you wish to override that, you can pass in your own custom message instead.
113
+ ### Formatting
131
114
 
132
- #### Internationalization (I18n)
115
+ `details` and `line_items` allow inline formatting with Prawn. This allows you to use HTML tags to format text: `<b>` `<i>` `<u>` `<strikethrough>` `<sub>` `<sup>` `<font>` `<color>` `<link>`
116
+
117
+ See [the Prawn docs](https://prawnpdf.org/api-docs/2.3.0/Prawn/Text.html#text-instance_method) for more information.
118
+
119
+ ### Internationalization (I18n)
133
120
 
134
121
  You can use `I18n.t` when rendering your receipts to internationalize them.
135
122
 
@@ -141,21 +128,53 @@ line_items: [
141
128
  ]
142
129
  ```
143
130
 
144
- ## Rendering the Receipt PDF in your Controller
131
+ ### Custom PDF Content
132
+
133
+ You can change the entire PDF content by instantiating an Receipts object without any options.
134
+
135
+ ```ruby
136
+ receipt = Receipts::Receipt.new # creates an empty PDF
137
+ ```
138
+
139
+ Each Receipts object inherits from Prawn::Document. This allows you to choose what is rendered and include any custom Prawn content you like.
140
+
141
+ ```ruby
142
+ receipt.text("hello world")
143
+ ```
144
+
145
+ You can also use the Receipts helpers in your custom PDFs at the current cursor position.
146
+
147
+ ```ruby
148
+ receipt.text("Custom header")
149
+ receipt.render_line_items([
150
+ ["my line items"]
151
+ ])
152
+ receipt.render_footer("This is a custom footer using the Receipts helper")
153
+ ```
154
+
155
+ ### Rendering PDFs
156
+
157
+ To render a PDF in memory, use `render`. This is recommended for serving PDFs in your Rails controllers.
158
+
159
+ ```ruby
160
+ receipt.render
161
+ ```
162
+
163
+ To render a PDF to disk, use `render_file`:
164
+
165
+ ```ruby
166
+ receipt.render_file "receipt.pdf"
167
+ ```
168
+
169
+ ## Rendering PDFs in Rails controller actions
145
170
 
146
- Here we have a charges controller that responds to the show action. When
147
- you visit it with the PDF format, it calls the `receipt` method that we
148
- just created on the `Charge` model.
171
+ Here's an example Rails controller action you can use for serving PDFs. We'll first look up the database record for the `Charge` we want to render a receipt for.
149
172
 
150
- We set the filename to be the date plus the product name. You can
151
- customize the filename to your liking.
173
+ The `Charge` model has a `receipt` method that returns a `Receipts::Receipt` instance with all the receipt data filled out.
152
174
 
153
- Next we set the response type which will be `application/pdf`
175
+ Then we can `render` to generate the PDF in memory. This produces a String with the raw PDF data in it.
154
176
 
155
- Optionally we can set the `disposition` to `:inline` which allows us to
156
- render the PDF in the browser without forcing the download. If you
157
- delete this option or change it to `:attachment` then the receipt will
158
- be downloaded instead.
177
+ Using `send_data` from Rails, we can send the PDF contents and provide the browser with a recommended filename, content type and disposition.
159
178
 
160
179
  ```ruby
161
180
  class ChargesController < ApplicationController
@@ -164,12 +183,7 @@ class ChargesController < ApplicationController
164
183
 
165
184
  def show
166
185
  respond_to do |format|
167
- format.pdf {
168
- send_data @charge.receipt.render,
169
- filename: "#{@charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
170
- type: "application/pdf",
171
- disposition: :inline
172
- }
186
+ format.pdf { send_pdf }
173
187
  end
174
188
  end
175
189
 
@@ -178,13 +192,18 @@ class ChargesController < ApplicationController
178
192
  def set_charge
179
193
  @charge = current_user.charges.find(params[:id])
180
194
  end
195
+
196
+ def send_pdf
197
+ # Render the PDF in memory and send as the response
198
+ send_data @charge.receipt.render,
199
+ filename: "#{@charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
200
+ type: "application/pdf",
201
+ disposition: :inline # or :attachment to download
202
+ end
181
203
  end
182
204
  ```
183
205
 
184
- And that's it! Just create a `link_to` to your charge with the format of
185
- `pdf` and you're good to go.
186
-
187
- For example:
206
+ Then, just `link_to` to your charge with the format of `pdf`. For example:
188
207
 
189
208
  ```ruby
190
209
  # config/routes.rb
@@ -192,93 +211,78 @@ resources :charges
192
211
  ```
193
212
 
194
213
  ```erb
195
- <%= link_to "Download Receipt", charge_path(@charge, format: :pdf) %>
214
+ <%= link_to "View Receipt", charge_path(@charge, format: :pdf) %>
196
215
  ```
197
216
 
198
217
  ## Invoices
199
218
 
200
- Invoices follow the exact same set of steps as above, with a few minor changes and have a few extra arguments you can use:
201
-
202
- * `issue_date` - Date the invoice was issued
203
-
204
- * `due_date` - Date the invoice payment is due
205
-
206
- * `status` - A status for the invoice (Pending, Paid, etc)
207
-
208
- * `bill_to` - A string or Array of lines with billing details
209
-
210
- You can also use line_items to flexibly generate and display the table with items in it, including subtotal, taxes, and total amount.
219
+ Invoices follow the exact same set of steps as above. You'll simply want to modify the `details` to include other information for the Invoice such as the Issue Date, Due Date, etc.
211
220
 
212
221
  ```ruby
213
- Receipts::Invoice.new(
214
- id: "123",
215
- issue_date: Date.today,
216
- due_date: Date.today + 30,
217
- status: "<b><color rgb='#5eba7d'>PAID</color></b>",
218
- bill_to: [
219
- "GoRails, LLC",
220
- "123 Fake Street",
221
- "New York City, NY 10012",
222
- nil,
223
- "mail@example.com",
224
- ],
225
- company: {
226
- name: "GoRails, LLC",
227
- address: "123 Fake Street\nNew York City, NY 10012",
228
- email: "support@example.com",
229
- logo: File.expand_path("./examples/gorails.png")
230
- },
231
- line_items: [
232
- ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
233
- ["GoRails Subscription", "$19.00", "1", "$19.00"],
234
- [nil, nil, "Subtotal", "$19.00"],
235
- [nil, nil, "Tax Rate", "0%"],
236
- [nil, nil, "Total", "$19.00"],
237
- ],
238
- )
222
+ Receipts::Invoice.new(
223
+ details: [
224
+ ["Invoice Number", "123"],
225
+ ["Issue Date", Date.today.strftime("%B %d, %Y")],
226
+ ["Due Date", Date.today.strftime("%B %d, %Y")],
227
+ ["Status", "<b><color rgb='#5eba7d'>PAID</color></b>"]
228
+ ],
229
+ recipient: [
230
+ "<b>Bill To</b>",
231
+ "Customer",
232
+ "Address",
233
+ "City, State Zipcode",
234
+ "customer@example.org"
235
+ ],
236
+ company: {
237
+ name: "Example, LLC",
238
+ address: "123 Fake Street\nNew York City, NY 10012",
239
+ phone: "(555) 867-5309",
240
+ email: "support@example.com",
241
+ logo: File.expand_path("./examples/images/logo.png")
242
+ },
243
+ line_items: [
244
+ ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
245
+ ["Subscription", "$19.00", "1", "$19.00"],
246
+ [nil, nil, "Subtotal", "$19.00"],
247
+ [nil, nil, "Tax Rate", "0%"],
248
+ [nil, nil, "Amount Due", "$19.00"]
249
+ ]
250
+ )
239
251
  ```
240
252
 
241
253
  ## Statements
242
254
 
243
- Statements follow the exact same set of steps as receipts, with a few minor changes and have a few extra arguments you can use:
244
-
245
- * `issue_date` - Date the invoice was issued
246
-
247
- * `start_date` - The start date of the statement period
248
-
249
- * `start_date` - The end date of the statement period
250
-
251
- * `bill_to` - A string or Array of lines with account details
252
-
253
- You can also use line_items to flexibly generate and display the table with items in it, including subtotal, taxes, and total amount.
255
+ Statements follow the exact same set of steps as above. You'll simply want to modify the `details` to include other information for the Invoice such as the Issue Date, Start and End Dates, etc.
254
256
 
255
257
  ```ruby
256
- Receipts::Statement.new(
257
- id: "123",
258
- issue_date: Date.today,
259
- start_date: Date.today - 30,
260
- end_date: Date.today,
261
- bill_to: [
262
- "GoRails, LLC",
263
- "123 Fake Street",
264
- "New York City, NY 10012",
265
- nil,
266
- "mail@example.com",
267
- ],
268
- company: {
269
- name: "GoRails, LLC",
270
- address: "123 Fake Street\nNew York City, NY 10012",
271
- email: "support@example.com",
272
- logo: File.expand_path("./examples/gorails.png")
273
- },
274
- line_items: [
275
- ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
276
- ["GoRails Subscription", "$19.00", "1", "$19.00"],
277
- [nil, nil, "Subtotal", "$19.00"],
278
- [nil, nil, "Tax Rate", "0%"],
279
- [nil, nil, "Total", "$19.00"],
280
- ],
281
- )
258
+ Receipts::Statement.new(
259
+ details: [
260
+ ["Statement Number", "123"],
261
+ ["Issue Date", Date.today.strftime("%B %d, %Y")],
262
+ ["Period", "#{(Date.today - 30).strftime("%B %d, %Y")} - #{Date.today.strftime("%B %d, %Y")}"]
263
+ ],
264
+ recipient: [
265
+ "<b>Bill To</b>",
266
+ "Customer",
267
+ "Address",
268
+ "City, State Zipcode",
269
+ "customer@example.org"
270
+ ],
271
+ company: {
272
+ name: "Example, LLC",
273
+ address: "123 Fake Street\nNew York City, NY 10012",
274
+ email: "support@example.com",
275
+ phone: "(555) 867-5309",
276
+ logo: File.expand_path("./examples/images/logo.png")
277
+ },
278
+ line_items: [
279
+ ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
280
+ ["Subscription", "$19.00", "1", "$19.00"],
281
+ [nil, nil, "Subtotal", "$19.00"],
282
+ [nil, nil, "Tax Rate", "0%"],
283
+ [nil, nil, "Total", "$19.00"]
284
+ ]
285
+ )
282
286
  ```
283
287
 
284
288
  ## Contributing
data/Rakefile CHANGED
@@ -1,12 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "open-uri"
4
+ require "rake/testtask"
4
5
 
5
- RSpec::Core::RakeTask.new("spec")
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
6
11
 
7
- # If you want to make this the default task
8
- task default: :spec
9
- task test: :spec
12
+ task default: :test
10
13
 
11
14
  task :console do
12
15
  exec "irb -r receipts -I ./lib"
@@ -14,60 +17,74 @@ end
14
17
 
15
18
  task :examples do
16
19
  [:receipt, :invoice, :statement].each { |t| Rake::Task[t].invoke }
17
-
18
20
  puts "Use `open examples` to view example PDFs."
19
21
  end
20
22
 
21
23
  task :receipt do
22
24
  require "./lib/receipts"
23
25
 
24
- Receipts::Receipt.new(
25
- id: "123",
26
- subheading: "RECEIPT FOR CHARGE #1",
27
- product: "GoRails",
26
+ r = Receipts::Receipt.new(
27
+ recipient: [
28
+ "<b>Bill To</b>",
29
+ "Customer",
30
+ "Address",
31
+ "City, State Zipcode",
32
+ "customer@example.org"
33
+ ],
28
34
  company: {
29
- name: "GoRails, LLC",
35
+ name: "Example, LLC",
30
36
  address: "123 Fake Street\nNew York City, NY 10012",
37
+ phone: "(555) 867-5309",
31
38
  email: "support@example.com",
32
- logo: "https://www.ruby-lang.org/images/header-ruby-logo@2x.png"
39
+ logo: File.expand_path("./examples/images/logo.png")
33
40
  },
41
+ details: [
42
+ ["Receipt Number", "123"],
43
+ ["Date paid", Date.today.strftime("%B %d, %Y")],
44
+ ["Payment method", "ACH super long super long super long super long super long"]
45
+ ],
34
46
  line_items: [
35
- ["Date", Time.now.to_s],
36
- ["Account Billed", "Example User (user@example.com)"],
37
- ["Product", "GoRails"],
38
- ["Amount", "$19.00"],
39
- ["Charged to", "Visa (**** **** **** 1234)"],
40
- ["Transaction ID", "123456"]
47
+ ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
48
+ ["Subscription", "$19.00", "1", "$19.00"],
49
+ [nil, nil, "Subtotal", "$19.00"],
50
+ [nil, nil, "Tax", "$1.12"],
51
+ [nil, nil, "Total", "$20.12"],
52
+ [nil, nil, "<b>Amount paid</b>", "$20.12"],
53
+ [nil, nil, "Refunded on #{Date.today.strftime("%B %d, %Y")}", "$5.00"]
41
54
  ]
42
- ).render_file "examples/receipt.pdf"
55
+ )
56
+ r.render_file "examples/receipt.pdf"
43
57
  end
44
58
 
45
59
  task :invoice do
46
60
  require "./lib/receipts"
47
61
 
48
62
  Receipts::Invoice.new(
49
- id: "123",
50
- issue_date: Date.today,
51
- due_date: Date.today + 30,
52
- status: "<b><color rgb='#5eba7d'>PAID</color></b>",
53
- bill_to: [
54
- "GoRails, LLC",
63
+ details: [
64
+ ["Invoice Number", "123"],
65
+ ["Issue Date", Date.today.strftime("%B %d, %Y")],
66
+ ["Due Date", Date.today.strftime("%B %d, %Y")],
67
+ ["Status", "<b><color rgb='#5eba7d'>PAID</color></b>"]
68
+ ],
69
+ recipient: [
70
+ "<b>Bill To</b>",
71
+ "Customer",
55
72
  "Address",
56
73
  "City, State Zipcode",
57
- nil,
58
- "mail@example.com"
74
+ "customer@example.org"
59
75
  ],
60
76
  company: {
61
- name: "GoRails, LLC",
77
+ name: "Example, LLC",
62
78
  address: "123 Fake Street\nNew York City, NY 10012",
79
+ phone: "(555) 867-5309",
63
80
  email: "support@example.com",
64
- # logo: Rails.root.join("app/assets/images/gorails.png")
65
- # logo: File.expand_path("./examples/gorails.png")
66
- logo: File.open("./examples/gorails.png")
81
+ # logo: Rails.root.join("app/assets/images/logo.png")
82
+ # logo: File.open("./examples/images/logo.png")
83
+ logo: File.expand_path("./examples/images/logo.png")
67
84
  },
68
85
  line_items: [
69
86
  ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
70
- ["GoRails Subscription", "$19.00", "1", "$19.00"],
87
+ ["Subscription", "$19.00", "1", "$19.00"],
71
88
  [nil, nil, "Subtotal", "$19.00"],
72
89
  [nil, nil, "Tax Rate", "0%"],
73
90
  [nil, nil, "Amount Due", "$19.00"]
@@ -79,26 +96,28 @@ task :statement do
79
96
  require "./lib/receipts"
80
97
 
81
98
  Receipts::Statement.new(
82
- id: "123",
83
- issue_date: Date.today,
84
- start_date: Date.today - 30,
85
- end_date: Date.today,
86
- bill_to: [
87
- "GoRails, LLC",
88
- "123 Fake Street",
89
- "New York City, NY 10012",
90
- nil,
91
- "mail@example.com"
99
+ details: [
100
+ ["Statement Number", "123"],
101
+ ["Issue Date", Date.today.strftime("%B %d, %Y")],
102
+ ["Period", "#{(Date.today - 30).strftime("%B %d, %Y")} - #{Date.today.strftime("%B %d, %Y")}"]
103
+ ],
104
+ recipient: [
105
+ "<b>Bill To</b>",
106
+ "Customer",
107
+ "Address",
108
+ "City, State Zipcode",
109
+ "customer@example.org"
92
110
  ],
93
111
  company: {
94
- name: "GoRails, LLC",
112
+ name: "Example, LLC",
95
113
  address: "123 Fake Street\nNew York City, NY 10012",
96
114
  email: "support@example.com",
97
- logo: File.expand_path("./examples/gorails.png")
115
+ phone: "(555) 867-5309",
116
+ logo: File.expand_path("./examples/images/logo.png")
98
117
  },
99
118
  line_items: [
100
119
  ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
101
- ["GoRails Subscription", "$19.00", "1", "$19.00"],
120
+ ["Subscription", "$19.00", "1", "$19.00"],
102
121
  [nil, nil, "Subtotal", "$19.00"],
103
122
  [nil, nil, "Tax Rate", "0%"],
104
123
  [nil, nil, "Total", "$19.00"]