fix: improve get_last_completed_cycle and fix test helpers
- Fix get_last_completed_cycle to find most recent completed cycle - Fix create_cycle helpers to delete auto-generated cycles first - Fix Ash.destroy return value handling - Fix form selectors to use specific IDs - Fix URL parameter names for filters - Fix Ash.read_one return value expectations in tests
This commit is contained in:
parent
ab7fa38010
commit
128c712dbc
12 changed files with 177 additions and 43 deletions
|
|
@ -126,11 +126,17 @@ defmodule MvWeb.Helpers.MembershipFeeHelpers do
|
|||
fee_type ->
|
||||
cycles = member.membership_fee_cycles || []
|
||||
|
||||
cycles
|
||||
|> Enum.filter(fn cycle ->
|
||||
CalendarCycles.last_completed_cycle?(cycle.cycle_start, fee_type.interval, today)
|
||||
end)
|
||||
|> List.first()
|
||||
# Get all completed cycles (cycle_end < today)
|
||||
completed_cycles =
|
||||
cycles
|
||||
|> Enum.filter(fn cycle ->
|
||||
cycle_end = CalendarCycles.calculate_cycle_end(cycle.cycle_start, fee_type.interval)
|
||||
Date.compare(today, cycle_end) == :gt
|
||||
end)
|
||||
|
||||
# Return the most recent completed cycle (highest cycle_start)
|
||||
completed_cycles
|
||||
|> Enum.max_by(& &1.cycle_start, Date, fn -> nil end)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue