analytics/lib/plausible_web/views/auth_view.ex
Uku Taht 9476ccf95c
Yearly billing (#58)
* Add yearly billing options

* Add new subscription names

* Add note about yearly billing in the email

* Add a test for change_plan function

* Add allowance function back in

* Test billing controller endpoint
2020-04-21 14:11:38 +03:00

33 lines
766 B
Elixir

defmodule PlausibleWeb.AuthView do
use PlausibleWeb, :view
@subscription_names %{
"558018" => "10k / monthly",
"558745" => "100k / monthly",
"558746" => "1m / monthly",
"572810" => "10k / yearly",
"590752" => "100k / yearly",
"590753" => "1m / yearly",
"free_10k" => "10k / free"
}
def subscription_name(subscription) do
@subscription_names[subscription.paddle_plan_id]
end
def delimit_integer(number) do
Integer.to_charlist(number)
|> :lists.reverse()
|> delimit_integer([])
|> String.Chars.to_string()
end
defp delimit_integer([a, b, c, d | tail], acc) do
delimit_integer([d | tail], [",", c, b, a | acc])
end
defp delimit_integer(list, acc) do
:lists.reverse(list) ++ acc
end
end