refactor(overview): use English identifier as_of_date for point-in-time filter

This commit is contained in:
Simon 2026-07-10 16:27:16 +02:00
parent ce877463d6
commit 0acd12360f
11 changed files with 113 additions and 112 deletions

View file

@ -46,7 +46,7 @@ defmodule MvWeb.MemberLive.Index.OverviewQuery do
opts[:boolean_custom_fields]
)
|> apply_date_filters(opts[:date_filters])
|> apply_stichtag_filter(opts[:stichtag])
|> apply_as_of_date_filter(opts[:as_of_date])
|> apply_custom_date_filters(opts[:date_filters], opts[:date_custom_fields])
|> apply_payment_filter(opts[:payment_filter], payment_period(opts))
|> apply_suspended_filter(opts[:suspended], payment_period(opts))
@ -285,20 +285,20 @@ defmodule MvWeb.MemberLive.Index.OverviewQuery do
defp apply_custom_date_filters(query, _filters, _custom_fields), do: query
# ---------------------------------------------------------------------------
# Point-in-time membership ("Stichtag"): a member counts as a member on the
# Point-in-time membership (as-of date): a member counts as a member on the
# reference date X iff it had joined by X and had not yet left as of X
# (§1.24/§2.6). "Left as of X" means a non-nil exit_date at or before X, so an
# exit_date strictly after X (or nil) still counts as a member on X.
# ---------------------------------------------------------------------------
defp apply_stichtag_filter(query, %Date{} = x) do
defp apply_as_of_date_filter(query, %Date{} = x) do
Ash.Query.filter(
query,
expr(join_date <= ^x and (is_nil(exit_date) or exit_date > ^x))
)
end
defp apply_stichtag_filter(query, _), do: query
defp apply_as_of_date_filter(query, _), do: query
# ---------------------------------------------------------------------------
# Sort (always append the unique id tie-breaker for keyset stability)
@ -327,7 +327,7 @@ defmodule MvWeb.MemberLive.Index.OverviewQuery do
])
end
# "Beiträge" (payment) column: sort DB-side by the period-scoped unpaid-cycle
# Fees (payment) column: sort DB-side by the period-scoped unpaid-cycle
# count (§1.27). The count calculation takes the active period as arguments so
# the sort key matches the displayed value; the id tie-breaker keeps keyset
# pages stable across equal counts.