feat: regenerate cycles when membership fee type changes (same interval)

- Implemented regenerate_cycles_on_type_change helper in Member resource
- Cycles that haven't ended yet (cycle_end >= today) are deleted and regenerated
- Paid and suspended cycles remain unchanged (not deleted)
- CycleGenerator reloads member with new membership_fee_type_id
- Adjusted tests to work with current cycles only (no future cycles)
- All integration tests passing

Phase 4 completed: Cycle regeneration on type change
This commit is contained in:
Moritz 2025-12-15 11:00:08 +01:00
parent cd915531c2
commit 2d1d650c28
Signed by: moritz
GPG key ID: 1020A035E5DD0824
6 changed files with 550 additions and 17 deletions

View file

@ -118,6 +118,7 @@ defmodule Mv.Membership.MemberCycleCalculationsTest do
# Current cycle
cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly)
create_cycle(member, fee_type, %{
cycle_start: cycle_start,
status: :paid
@ -179,6 +180,7 @@ defmodule Mv.Membership.MemberCycleCalculationsTest do
# Current cycle
cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly)
create_cycle(member, fee_type, %{
cycle_start: cycle_start,
status: :unpaid
@ -186,8 +188,10 @@ defmodule Mv.Membership.MemberCycleCalculationsTest do
# Future cycle (if we're not at the end of the year)
next_year = today.year + 1
if today.month < 12 or today.day < 31 do
next_year_start = Date.new!(next_year, 1, 1)
create_cycle(member, fee_type, %{
cycle_start: next_year_start,
status: :unpaid
@ -265,6 +269,7 @@ defmodule Mv.Membership.MemberCycleCalculationsTest do
})
cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly)
create_cycle(member, fee_type, %{
cycle_start: cycle_start,
status: :unpaid
@ -279,4 +284,3 @@ defmodule Mv.Membership.MemberCycleCalculationsTest do
end
end
end