Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
do not show invoices for free subscription (#2249)
RobertJoonas80e01fedd588
diff --git a/lib/plausible/billing/paddle_api.ex b/lib/plausible/billing/paddle_api.exindex 5325fd1d2c..820a329992 100644--- a/lib/plausible/billing/paddle_api.ex+++ b/lib/plausible/billing/paddle_api.ex@@ -92,8 +92,9 @@ defmodule Plausible.Billing.PaddleApi do@spec get_invoices(Plausible.Billing.Subscription.t()) ::{:ok, list()}| {:error, :request_failed}- | {:error, :no_subscription}- def get_invoices(nil), do: {:error, :no_subscription}+ | {:error, :no_invoices}+ def get_invoices(nil), do: {:error, :no_invoices}+ def get_invoices(%{paddle_subscription_id: nil}), do: {:error, :no_invoices}def get_invoices(subscription) doconfig = get_config()diff --git a/lib/plausible_web/templates/auth/user_settings.html.eex b/lib/plausible_web/templates/auth/user_settings.html.eexindex 9d1fdc3a94..6e82fb5163 100644--- a/lib/plausible_web/templates/auth/user_settings.html.eex+++ b/lib/plausible_web/templates/auth/user_settings.html.eex@@ -125,7 +125,7 @@</div><%= case @invoices do %>- <% {:error, :no_subscription} -> %>+ <% {:error, :no_invoices} -> %><% {:error, :request_failed} -> %><div class="max-w-2xl px-8 pt-6 pb-8 mx-auto mt-16 bg-white border-t-2 border-orange-200 rounded rounded-t-none shadow-md dark:bg-gray-800">diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exsindex 3db257d4db..2aaa0c482a 100644--- a/test/plausible_web/controllers/auth_controller_test.exs+++ b/test/plausible_web/controllers/auth_controller_test.exs@@ -557,7 +557,15 @@ defmodule PlausibleWeb.AuthControllerTest dotest "does not show invoice section for a user with no subscription", %{conn: conn} doconn = get(conn, "/settings")- assert !(html_response(conn, 200) =~ "Invoices")+ refute html_response(conn, 200) =~ "Invoices"+ end++ test "does not show invoice section for a free subscription", %{conn: conn, user: user} do+ Plausible.Billing.Subscription.free(%{user_id: user.id, currency_code: "EUR"})+ |> Repo.insert!()++ conn = get(conn, "/settings")+ refute html_response(conn, 200) =~ "Invoices"endenddiff --git a/test/support/paddle_api_mock.ex b/test/support/paddle_api_mock.exindex e44cec0aec..a6a7c46b43 100644--- a/test/support/paddle_api_mock.ex+++ b/test/support/paddle_api_mock.ex@@ -26,7 +26,8 @@ defmodule Plausible.PaddleApi.Mock do}}end- def get_invoices(nil), do: {:error, :no_subscription}+ def get_invoices(nil), do: {:error, :no_invoices}+ def get_invoices(%{paddle_subscription_id: nil}), do: {:error, :no_invoices}def get_invoices(subscription) docase subscription.paddle_subscription_id do