Cycle Management & Member Integration closes #279 #294

Merged
moritz merged 22 commits from feature/279_cycle_management into main 2025-12-18 15:01:58 +01:00

22 commits

Author SHA1 Message Date
017ee5bc0c
refactor: reduce nesting depth in process_batch function
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-18 15:00:45 +01:00
d720670fd2
fix: address notification handling review feedback
1. Fix misleading comment in async create_member path
2. Use skip_lock?: true in test case for create_member
3. Fix generate_cycles_for_all_members/1
2025-12-18 15:00:45 +01:00
c25ffdc034
refactor: implement proper notification handling via after_action hooks
Refactor notification handling according to Ash best practices
2025-12-18 15:00:44 +01:00
98b56fc406
fix: resolve notification handling and maintain after_action for cycle regeneration 2025-12-18 15:00:44 +01:00
ba0ece9dc6
fix: correct return_notifications? logic to prevent missed notifications
Fix the logic for return_notifications? in create_cycles
2025-12-18 15:00:44 +01:00
0783a2fe18
refactor: reduce nesting depth in regenerate_cycles_on_type_change
Split the function into smaller, focused functions to reduce nesting depth
2025-12-18 15:00:44 +01:00
66d0c9a702
fix: address code review points for cycle regeneration
1. Fix critical notifications bug
2. Fix today inconsistency
3. Add advisory lock around deletion
4. Improve helper function documentation
5. Improve error message UX
2025-12-18 15:00:44 +01:00
6158602598
refactor: reduce complexity of with_advisory_lock function
Split the complex with_advisory_lock function into smaller, focused
functions to improve readability and reduce cyclomatic complexity
2025-12-18 15:00:43 +01:00
d8e9c157bf
fix: prevent deadlocks by detecting existing transactions 2025-12-18 15:00:43 +01:00
9d7d06d430
test: update test to reflect nil assignment prevention 2025-12-18 15:00:43 +01:00
70e673034a
fix: remove unused variable warning in ValidateSameInterval 2025-12-18 15:00:43 +01:00
4867bb9470
docs: update architecture docs for atomic cycle regeneration 2025-12-18 15:00:43 +01:00
094ed857ed
test: add monthly interval tests for cycle calculations 2025-12-18 15:00:42 +01:00
9c18be61a8
test: remove Process.sleep from type change integration tests 2025-12-18 15:00:42 +01:00
0e8f492800
fix: prevent nil assignment for membership_fee_type_id
Reject attempts to set membership_fee_type_id to nil when a current type
exists.
2025-12-18 15:00:42 +01:00
6183fc6978
fix: implement fail-closed behavior in ValidateSameInterval
Change validation to fail closed instead of fail open when types cannot
be loaded. This prevents inconsistent data states and provides clearer
error messages to users.
2025-12-18 15:00:42 +01:00
69c9746974
fix: make cycle regeneration atomic on type change
Make cycle regeneration synchronous in the same transaction as the member
update to ensure atomicity.
2025-12-18 15:00:42 +01:00
f6e2ecd74b
refactor: reduce nesting depth and improve code readability
- Replace Enum.map |> Enum.join with Enum.map_join for efficiency
- Extract helper functions to reduce nesting depth from 4 to 2
- Rename is_current_cycle? to current_cycle? following Elixir conventions
2025-12-18 15:00:41 +01:00
b9fb115eb5
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
2025-12-18 15:00:41 +01:00
3177ea20dd
feat: add validation for same-interval membership fee type changes 2025-12-18 15:00:41 +01:00
43ec281242
feat: add cycle status calculations to Member resource 2025-12-18 15:00:41 +01:00
910a91aa74
feat: add status management actions to MembershipFeeCycle 2025-12-18 15:00:41 +01:00