mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
calculate the real revenue on stats after credit card fees
This commit is contained in:
parent
fbee506f88
commit
41c4a5a1ef
2 changed files with 17 additions and 1 deletions
|
@ -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
13
ext/float.rb
Normal 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
|
Loading…
Add table
Reference in a new issue