stripe_invoice 1.3.2 → 1.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6c62d186f30b26ee3f6f9c5e0741a8f5e855924
|
4
|
+
data.tar.gz: cc3d701733f07968d2fdf9ba1d9af4eb7c5f953a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f43f460652eef6aa0204be986a70a2239384f3557c6d7c3ede0a05ae38ca5b65dcb04d3787366dfca6adb50bca27681b28ef2553ac328d22df8e6f13f763a77
|
7
|
+
data.tar.gz: 0914d73f343604a061f854d02d394f1fcb4bd40ec8a42abb77143d1c5abb27d55b53ecd56b1ef7414182ae167c8dabbf84496434bf1b9b31315f9d77e7e8d45e
|
@@ -28,7 +28,7 @@ module StripeInvoice
|
|
28
28
|
country: country,
|
29
29
|
tax_number: charge.tax_number,
|
30
30
|
billing_address: charge.billing_address,
|
31
|
-
bt:
|
31
|
+
bt: charge.balance_transaction_object,
|
32
32
|
owner: owner,
|
33
33
|
}
|
34
34
|
puts "[#{self.class.name}##{__method__.to_s}] aggregating data #{charge.stripe_id}"
|
@@ -82,11 +82,13 @@ module StripeInvoice
|
|
82
82
|
result = []
|
83
83
|
charges.each_key do |key|
|
84
84
|
next if key.blank?
|
85
|
-
|
85
|
+
|
86
86
|
result << {
|
87
|
-
amount: charges[key].sum{|
|
88
|
-
currency: charges[key].first[:
|
89
|
-
tax_number: key
|
87
|
+
amount: (charges[key].sum {|charge| charge[:charge].balance_transaction_total_less_refunds}),
|
88
|
+
currency: charges[key].first[:bt][:currency],
|
89
|
+
tax_number: key,
|
90
|
+
country: (charges[key].first[:charge].owner.country ? charges[key].first[:charge].owner.country :
|
91
|
+
"CC: #{charges[key].first[:charge].source_country}")
|
90
92
|
}
|
91
93
|
end
|
92
94
|
|
@@ -41,10 +41,46 @@ module StripeInvoice
|
|
41
41
|
refunds.inject(0){ |total,refund| total + refund[:amount]}
|
42
42
|
end
|
43
43
|
|
44
|
+
def total_refund_transaction
|
45
|
+
refunds.inject(0) do |total, refund|
|
46
|
+
bt = Stripe::BalanceTransaction.retrieve(refund[:balance_transaction])
|
47
|
+
total + bt[:amount]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
def total_less_refunds
|
45
52
|
total - total_refund
|
46
53
|
end
|
47
54
|
|
55
|
+
def balance_transaction_object
|
56
|
+
@btobj ||= Stripe::BalanceTransaction.retrieve balance_transaction_sid
|
57
|
+
end
|
58
|
+
|
59
|
+
def balance_transaction_sid
|
60
|
+
self.indifferent_json[:balance_transaction]
|
61
|
+
end
|
62
|
+
|
63
|
+
def balance_transaction_currency
|
64
|
+
self.balance_transaction_object[:currency]
|
65
|
+
end
|
66
|
+
|
67
|
+
def balance_transaction_total_less_refunds
|
68
|
+
result = (balance_transaction_object[:amount] - self.total_refund_transaction)
|
69
|
+
puts "[#{self.class.name}##{__method__.to_s}] result for #{id}-#{tax_number}: #{result}"
|
70
|
+
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
# the country the source is registered in
|
75
|
+
def source_country
|
76
|
+
# source can only be accessed via Customer
|
77
|
+
cus = Stripe::Customer.retrieve self.indifferent_json[:customer]
|
78
|
+
# TODO this is wrong, because there might be multiple sources and I
|
79
|
+
# just randomly select the first one - also some source types might NOT even
|
80
|
+
# have a country information
|
81
|
+
cus.sources.data[0].country
|
82
|
+
end
|
83
|
+
|
48
84
|
# builds the invoice from the stripe CHARGE object
|
49
85
|
# OR updates the existing invoice if an invoice for that id exists
|
50
86
|
def self.create_from_stripe(stripe_charge)
|
@@ -29,7 +29,7 @@ prawn_document(:page_layout => :portrait) do |pdf|
|
|
29
29
|
pdf.start_new_page
|
30
30
|
pdf.font_size(17.5) { pdf.text "Volume per tax ID", :style => :bold }
|
31
31
|
volume_per_tax_number.each do |vptn_hash|
|
32
|
-
pdf.text "#{vptn_hash[:tax_number]}: #{format_stripe_currency(vptn_hash,:amount)}"
|
32
|
+
pdf.text "#{vptn_hash[:tax_number]}(#{vptn_hash[:country]}): #{format_stripe_currency(vptn_hash,:amount)}"
|
33
33
|
end
|
34
34
|
|
35
35
|
pdf.start_new_page
|
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.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Engelhardt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|