From ba0328469129a1e73c53b06b81e560fd68a3fa72 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Wed, 30 Mar 2022 10:09:33 -0400 Subject: [PATCH] Declines should be an Int 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. --- lib/customer_finacials.rb | 2 +- lib/financial_info.rb | 2 +- lib/transaction.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/customer_finacials.rb b/lib/customer_finacials.rb index 9841c50..924030c 100644 --- a/lib/customer_finacials.rb +++ b/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 diff --git a/lib/financial_info.rb b/lib/financial_info.rb index 8fb8cc9..ca394d7 100644 --- a/lib/financial_info.rb +++ b/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 diff --git a/lib/transaction.rb b/lib/transaction.rb index 72b1132..3885ee1 100644 --- a/lib/transaction.rb +++ b/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, -- 2.34.5