stripe_invoice 1.2.0 → 1.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ad53fd68f8da537d3b3c8678665e7bc9d54e7bd
|
4
|
+
data.tar.gz: df9c890143329314f5feed0dbcdcb0791725f6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8130919e62dbfe5a315297d1bec62b961661a6872111f5a35cf4fe408b441b65c797eac57483070b101a851fecc41695f5eb2af24694ce40d22d8b0c8c93b9c3
|
7
|
+
data.tar.gz: 407af7e36edaa23db23b90f7f7796e140a85d41c4b6e234089b2e56b92ec5e5a750cd7fe4f0c39665a060c27636ab63ea2da63514d47e78fcdd5042b4636c6d1
|
@@ -1,19 +1,20 @@
|
|
1
1
|
module StripeInvoice
|
2
2
|
class DJTaxReport
|
3
3
|
def initialize(year = 1.year.ago.year)
|
4
|
+
year = 2015
|
4
5
|
@year = year
|
5
6
|
end
|
6
7
|
|
7
8
|
|
8
9
|
def perform
|
9
|
-
puts "[
|
10
|
+
puts "[#{self.class.name}##{__method__.to_s}] computing tax report for #{@year}"
|
10
11
|
|
11
12
|
sicharges = StripeInvoice::Charge.where(
|
12
13
|
"date >= ? and date <= ?",
|
13
14
|
date_to_epoch("#{@year}-01-01"),
|
14
15
|
date_to_epoch("#{@year}-12-31"))
|
15
16
|
|
16
|
-
puts "[
|
17
|
+
puts "[#{self.class.name}##{__method__.to_s}] number of charges in year: #{sicharges.size}"
|
17
18
|
arr_data = []
|
18
19
|
sicharges.each do |charge|
|
19
20
|
owner = charge.owner
|
@@ -30,7 +31,7 @@ module StripeInvoice
|
|
30
31
|
bt: Stripe::BalanceTransaction.retrieve(charge.indifferent_json[:balance_transaction]),
|
31
32
|
owner: owner,
|
32
33
|
}
|
33
|
-
puts "[
|
34
|
+
puts "[#{self.class.name}##{__method__.to_s}] aggregating data #{charge.stripe_id}"
|
34
35
|
if charge.indifferent_json[:refunds].count > 0
|
35
36
|
arr_refunds = []
|
36
37
|
charge.indifferent_json[:refunds].each do |refund|
|
@@ -48,10 +49,13 @@ module StripeInvoice
|
|
48
49
|
arr_data << data
|
49
50
|
end
|
50
51
|
|
51
|
-
puts "[
|
52
|
+
puts "[#{self.class.name}##{__method__.to_s}] data collected; rendering view"
|
52
53
|
#res = InvoicesController.new.tax_report arr_data
|
53
54
|
res = Renderer.render template: "stripe_invoice/invoices/tax_report",
|
54
|
-
locals: {sicharges: arr_data,
|
55
|
+
locals: {sicharges: arr_data,
|
56
|
+
year: @year,
|
57
|
+
totals: totals(arr_data),
|
58
|
+
volume_per_tax_number: volume_per_tax_number(arr_data)},
|
55
59
|
formats: [:pdf]
|
56
60
|
|
57
61
|
InvoiceMailer.tax_report(res).deliver! #unless ::Rails.env.development?
|
@@ -70,6 +74,25 @@ module StripeInvoice
|
|
70
74
|
}
|
71
75
|
end
|
72
76
|
|
77
|
+
def volume_per_tax_number(sicharges)
|
78
|
+
puts "[#{self.class.name}##{__method__.to_s}] calculating volume per tax id"
|
79
|
+
charges = sicharges.group_by do |charge|
|
80
|
+
charge[:tax_number]
|
81
|
+
end
|
82
|
+
result = []
|
83
|
+
charges.each_key do |key|
|
84
|
+
next if key.blank?
|
85
|
+
|
86
|
+
result << {
|
87
|
+
amount: charges[key].sum{|char| char[:total] - char.sum{|ref| ref[:amount]}},
|
88
|
+
currency: charges[key].first[:currency],
|
89
|
+
tax_number: key
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
result
|
94
|
+
end
|
95
|
+
|
73
96
|
include ActionView::Helpers::NumberHelper
|
74
97
|
def total_transaction_volume(sicharges)
|
75
98
|
number_to_currency(sicharges.inject(0) {|sum, hash_ch| sum + hash_ch[:bt][:amount]} / 100.0,
|
@@ -26,6 +26,11 @@ prawn_document(:page_layout => :portrait) do |pdf|
|
|
26
26
|
table.column(1).width = 140
|
27
27
|
table.row(0).style(:border_width => 1, :borders => [:top], :color => 'dddddd')
|
28
28
|
end
|
29
|
+
pdf.start_new_page
|
30
|
+
pdf.font_size(17.5) { pdf.text "Volume per tax ID", :style => :bold }
|
31
|
+
volume_per_tax_number.each do |vptn_hash|
|
32
|
+
pdf.text "#{vptn_hash[:tax_number]}: #{format_stripe_currency(vptn_hash,:amount)}"
|
33
|
+
end
|
29
34
|
|
30
35
|
pdf.start_new_page
|
31
36
|
sicharges.each do |hash_ch|
|
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: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Engelhardt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
342
|
version: '0'
|
343
343
|
requirements: []
|
344
344
|
rubyforge_project:
|
345
|
-
rubygems_version: 2.
|
345
|
+
rubygems_version: 2.4.5.1
|
346
346
|
signing_key:
|
347
347
|
specification_version: 4
|
348
348
|
summary: Adds views, PDFs and automated emails if you are using Stripe/Koudoku for
|