Declines should be an Int

Christopher Vollick created

Previously this retured a string and everywhere that used it had to
convert it into an it, or handle it if it's nil.

That's dumb.
Now it's always an int, and `nil.to_i` is 0 anyway so I don't have to
check that either.

Change summary

lib/customer_finacials.rb | 2 +-
lib/financial_info.rb     | 2 +-
lib/transaction.rb        | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

Detailed changes

lib/customer_finacials.rb 🔗

@@ -31,7 +31,7 @@ class CustomerFinancials
 	end
 
 	def declines
-		REDIS.get("jmp_pay_decline-#{@customer_id}")
+		REDIS.get("jmp_pay_decline-#{@customer_id}").then(&:to_i)
 	end
 
 	def mark_decline

lib/financial_info.rb 🔗

@@ -17,7 +17,7 @@ class AdminFinancialInfo
 		]).then do |transactions, declines, payment_methods, btc_addresses|
 			new(
 				transactions: transactions,
-				declines: declines || 0,
+				declines: declines,
 				payment_methods: payment_methods, btc_addresses: btc_addresses
 			)
 		end

lib/transaction.rb 🔗

@@ -5,7 +5,7 @@ require "bigdecimal"
 class Transaction
 	def self.sale(customer, amount:, payment_method: nil)
 		customer.declines.then do |declines|
-			raise "too many declines" if declines.to_i >= 2
+			raise "too many declines" if declines >= 2
 
 			BRAINTREE.transaction.sale(
 				amount: amount,