stripe_invoice 0.4.1 → 0.4.2
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 +4 -4
- data/app/delayed_jobs/stripe_invoice/dj_tax_report.rb +24 -1
- data/app/mailers/stripe_invoice/invoice_mailer.rb +8 -7
- data/app/views/stripe_invoice/invoice_mailer/tax_report.text.erb +4 -0
- data/app/views/stripe_invoice/invoices/tax_report.pdf.prawn +18 -2
- data/lib/stripe_invoice/version.rb +1 -1
- data/lib/tasks/stripe_invoice_tasks.rake +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4242a3c58f8c9de6a698c8bad07af86ba3e9a2cd
|
4
|
+
data.tar.gz: 027b5f465b65caafeac60a58a6ebff931c27ef26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776db1e5aa2d16e979474cf242b942eed67b6eb471ac32e95a404dd471e7c96fcd79ead6f48a9ff10cdcdd6eaddc6025fbb82569abea3d383b64fd8102ac0589
|
7
|
+
data.tar.gz: bcdede71a52a9cafea9487a18411c4280b475c001a0a1113fe320dcb258d9f9d6b686ba53dbb255cb548cb7e3611a7ff2a716c08f2c987de44fcebf6ef2fd40a
|
@@ -49,7 +49,7 @@ module StripeInvoice
|
|
49
49
|
locals: {sicharges: arr_data, year: @year, totals: totals(arr_data)},
|
50
50
|
formats: [:pdf]
|
51
51
|
|
52
|
-
|
52
|
+
InvoiceMailer.tax_report(res).deliver! #unless ::Rails.env.development?
|
53
53
|
end
|
54
54
|
|
55
55
|
|
@@ -61,6 +61,7 @@ module StripeInvoice
|
|
61
61
|
def totals(sicharges)
|
62
62
|
result = {
|
63
63
|
transaction_volume: total_transaction_volume(sicharges),
|
64
|
+
transaction_volume_by_country: transaction_volume_by_country(sicharges),
|
64
65
|
}
|
65
66
|
end
|
66
67
|
|
@@ -69,5 +70,27 @@ module StripeInvoice
|
|
69
70
|
number_to_currency(sicharges.inject(0) {|sum, hash_ch| sum + hash_ch[:bt][:amount]} / 100.0,
|
70
71
|
unit: "#{sicharges.first[:bt][:currency].upcase} ")
|
71
72
|
end
|
73
|
+
|
74
|
+
def transaction_volume_by_country(sicharges)
|
75
|
+
result = {}
|
76
|
+
|
77
|
+
sicharges.each do |hash_ch|
|
78
|
+
# get value or 0 if not present
|
79
|
+
value = result.fetch(hash_ch[:owner].country) { 0 }
|
80
|
+
|
81
|
+
if hash_ch[:refunds]
|
82
|
+
hash_ch[:refunds].each do |refund|
|
83
|
+
value -= refund[:bt][:amount]
|
84
|
+
end
|
85
|
+
end # deduct refunds
|
86
|
+
result[hash_ch[:owner].country] = value + hash_ch[:bt][:amount]
|
87
|
+
end
|
88
|
+
|
89
|
+
result.each do |key, value|
|
90
|
+
result[key] = value / 100.0
|
91
|
+
end
|
92
|
+
|
93
|
+
result.with_indifferent_access
|
94
|
+
end
|
72
95
|
end
|
73
96
|
end
|
@@ -20,16 +20,17 @@ module StripeInvoice
|
|
20
20
|
end
|
21
21
|
|
22
22
|
|
23
|
-
def tax_report
|
24
|
-
attachments['
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def tax_report(rendered_pdf)
|
24
|
+
attachments['income-report.pdf'] = rendered_pdf # File.read(::Rails.root.join('tmp', 'tax_report.pdf'))
|
25
|
+
# {
|
26
|
+
# content: File.read(::Rails.root.join('tmp', 'tax_report.pdf')),
|
27
|
+
# mime_type: "application/pdf"
|
28
|
+
# }
|
28
29
|
|
29
30
|
# sends the email to the default from address
|
30
31
|
addr_to = ActionMailer::Base.default[:from]
|
31
|
-
mail subject: "
|
32
|
-
puts "[InvoiceMailer]
|
32
|
+
mail subject: "Income report", to: addr_to
|
33
|
+
puts "[InvoiceMailer] income report sent to #{addr_to}"
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -4,12 +4,28 @@ prawn_document(:page_layout => :portrait) do |pdf|
|
|
4
4
|
pdf.fill_color "333333"
|
5
5
|
pdf.font_size = 14
|
6
6
|
|
7
|
-
pdf.font_size(17.5) { pdf.text "
|
8
|
-
|
7
|
+
pdf.font_size(17.5) { pdf.text "Income Report", :style => :bold }
|
8
|
+
pdf.text "DO NOT USE THIS DATA FOR REPORTING TO YOUR TAX AUTHORITY OR ANYTHING WHERE THAT DATA NEEDS TO BE ACCURATE." +
|
9
|
+
"I CAN NOT BE HELD ACCOUNTABLE FOR ANY DAMAGE DONE FROM USING THIS DATA"
|
9
10
|
|
10
11
|
pdf.move_down 10
|
11
12
|
pdf.text "Total charges in #{year}: #{sicharges.size}"
|
12
13
|
pdf.text "Total transactions: #{totals[:transaction_volume]}"
|
14
|
+
|
15
|
+
rows = [["Country", "Transaction volume"]]
|
16
|
+
bt_unit = sicharges.first[:bt][:currency].upcase
|
17
|
+
totals[:transaction_volume_by_country].each do |country, volume|
|
18
|
+
rows << [country, number_to_currency(volume, unit: "#{bt_unit} ")]
|
19
|
+
end
|
20
|
+
|
21
|
+
pdf.table(rows,:cell_style => { :border_width => 1,:border_color=> 'C1C1C1', :width=>'100%' }) do |table|
|
22
|
+
table.column(0).style(:align => :left)
|
23
|
+
table.column(1).style(:align => :right)
|
24
|
+
table.column(0).width = 320
|
25
|
+
table.column(1).width = 140
|
26
|
+
table.row(0).style(:border_width => 1, :borders => [:top], :color => 'dddddd')
|
27
|
+
end
|
28
|
+
|
13
29
|
pdf.start_new_page
|
14
30
|
sicharges.each do |hash_ch|
|
15
31
|
pdf.text "Invoice: #{hash_ch[:charge].invoice_number}" +
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe_invoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Engelhardt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- app/views/layouts/stripe_invoice/application.html.erb
|
224
224
|
- app/views/stripe_invoice/invoice_mailer/new_invoice.text.erb
|
225
225
|
- app/views/stripe_invoice/invoice_mailer/refund_invoice.text.erb
|
226
|
+
- app/views/stripe_invoice/invoice_mailer/tax_report.text.erb
|
226
227
|
- app/views/stripe_invoice/invoices/index.html.haml
|
227
228
|
- app/views/stripe_invoice/invoices/show.html.haml
|
228
229
|
- app/views/stripe_invoice/invoices/show.pdf.prawn
|