Fix create_fee_type default arg warning in StatisticsTest
This commit is contained in:
parent
99aa8969f0
commit
f2d7684b47
1 changed files with 33 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ defmodule Mv.StatisticsTest do
|
|||
%{actor: actor}
|
||||
end
|
||||
|
||||
defp create_fee_type(actor, attrs \\ %{}) do
|
||||
defp create_fee_type(actor, attrs) do
|
||||
MembershipFeeType
|
||||
|> Ash.Changeset.for_create(
|
||||
:create,
|
||||
|
|
@ -162,6 +162,38 @@ defmodule Mv.StatisticsTest do
|
|||
assert Decimal.equal?(result.unpaid, Decimal.new(0))
|
||||
assert Decimal.equal?(result.suspended, Decimal.new("50.00"))
|
||||
end
|
||||
|
||||
test "when fee_type_id is passed in opts, returns only cycles of that fee type", %{
|
||||
actor: actor
|
||||
} do
|
||||
fee_type_a = create_fee_type(actor, %{amount: Decimal.new("30.00")})
|
||||
fee_type_b = create_fee_type(actor, %{amount: Decimal.new("70.00")})
|
||||
|
||||
_m1 =
|
||||
Mv.Fixtures.member_fixture(%{
|
||||
join_date: ~D[2020-01-01],
|
||||
membership_fee_type_id: fee_type_a.id
|
||||
})
|
||||
|
||||
_m2 =
|
||||
Mv.Fixtures.member_fixture(%{
|
||||
join_date: ~D[2020-01-01],
|
||||
membership_fee_type_id: fee_type_b.id
|
||||
})
|
||||
|
||||
# Without filter: both fee types' cycles (2024)
|
||||
all_result = Statistics.cycle_totals_by_year(2024, actor: actor)
|
||||
assert Decimal.equal?(all_result.total, Decimal.new("100.00"))
|
||||
|
||||
# With fee_type_id as string (as from form/URL): only that type's cycles
|
||||
opts_a = [actor: actor, fee_type_id: to_string(fee_type_a.id)]
|
||||
result_a = Statistics.cycle_totals_by_year(2024, opts_a)
|
||||
assert Decimal.equal?(result_a.total, Decimal.new("30.00"))
|
||||
|
||||
opts_b = [actor: actor, fee_type_id: to_string(fee_type_b.id)]
|
||||
result_b = Statistics.cycle_totals_by_year(2024, opts_b)
|
||||
assert Decimal.equal?(result_b.total, Decimal.new("70.00"))
|
||||
end
|
||||
end
|
||||
|
||||
describe "open_amount_total/1" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue