calculate the real revenue on stats after credit card fees

This commit is contained in:
Kyle Drake 2015-03-01 11:30:21 -08:00
parent fbee506f88
commit 41c4a5a1ef
2 changed files with 17 additions and 1 deletions

View file

@ -56,7 +56,10 @@ get '/stats/?' do
sub[:status] = 'active'
plan = customer[:subscriptions][:data].first[:plan]
sub[:amount] = (plan[:amount] / 100.0).round(2)
sub[:amount_without_fees] = (plan[:amount] / 100.0).round(2)
sub[:percentage_fee] = (sub[:amount_without_fees]/(100/2.9)).ceil_to(2)
sub[:fixed_fee] = 0.30
sub[:amount] = sub[:amount_without_fees] - sub[:percentage_fee] - sub[:fixed_fee]
if(plan[:interval] == 'year')
sub[:amount] = (sub[:amount] / 12).round(2)

13
ext/float.rb Normal file
View file

@ -0,0 +1,13 @@
class Float
def round_to(x)
(self * 10**x).round.to_f / 10**x
end
def ceil_to(x)
(self * 10**x).ceil.to_f / 10**x
end
def floor_to(x)
(self * 10**x).floor.to_f / 10**x
end
end