Commit graph

268 commits

Author SHA1 Message Date
e0702240d3
feat: add membership fee type name to payment data section
- Display type name alongside amount, interval, and cycle statuses
- Improves clarity by showing which membership fee type is assigned
2025-12-18 15:08:34 +01:00
cd46478024
refactor: optimize format_currency using pipe operator
- Replace double assignment of normalized_str with pipe operator
- Improves code readability and follows Elixir best practices
2025-12-18 15:08:34 +01:00
4c66628802
fix: extract form values directly from form fields to preserve them
- Change get_existing_form_values to read from form[:field].value
- This ensures current form state is preserved when only interval changes
- Fixes issue where name and amount were cleared on interval selection
2025-12-18 15:08:33 +01:00
aece03c9c2
feat: show both last and current cycle status in payment data
- Add current cycle status calculation and display
- Show both Last Cycle and Current Cycle status badges
- Replace single Status field with two separate fields
2025-12-18 15:08:33 +01:00
e8e47fd92a
fix: remove unused variable in format_currency function
- Replace unused amount_str variable with normalized_str
- Ensure consistent variable naming throughout function
2025-12-18 15:08:33 +01:00
8ed9adeea0
fix: preserve form values when only interval field changes
- Merge existing form values with new params to prevent field loss
- Add get_existing_form_values helper to extract current form state
- Fixes issue where name and amount were cleared when selecting interval
2025-12-18 15:08:33 +01:00
5460ebdd5a
feat: add payment data section with membership fee type info
- Add Payment Data section showing membership fee amount, interval, and last cycle status
- Use real membership fee type data instead of mockup
- Calculate last cycle status from loaded cycles
2025-12-18 15:08:32 +01:00
bc989422e2
refactor: reduce function nesting depth to fix Credo warnings
Extract nested conditionals into separate helper functions:
- check_amount_change/2 and related helpers in MembershipFeeTypeLive.Form
- check_interval_change/2 and related helpers in MemberLive.Form

This reduces nesting depth from 3 to 2, improving code readability.
2025-12-18 15:08:32 +01:00
1fde2985e5
feat: add routes for membership fee types admin
- GET /membership_fee_types - List view
- GET /membership_fee_types/new - Create form
- GET /membership_fee_types/:id/edit - Edit form
2025-12-18 15:08:32 +01:00
810a54c11f
feat: add membership fee types admin interface
- Add list view showing name, amount, interval, member count
- Add create/edit forms for membership fee types
- Gray out interval field on edit (immutable)
- Show warning on amount change with impact information
- Prevent deletion if type is in use
2025-12-18 15:08:31 +01:00
35cafd6e6a
feat: add membership fee type dropdown to member form
- Add membership fee type selection in member create/edit form
- Show warning if different interval selected
- Filter available types to same interval only
2025-12-18 15:08:31 +01:00
920cae656e
feat: add membership fees section to member detail view
- Add membership fees section with cycle table
- Display cycles with interval, amount, status, and actions
- Add membership fee type dropdown (same interval only)
- Add status change actions (mark as paid/suspended/unpaid)
- Add cycle regeneration (manual and missing cycles)
- Add cycle amount editing
- Add cycle deletion with confirmation
2025-12-18 15:08:31 +01:00
99dc17bf4d
feat: add membership fee status column to member list
- Add status column showing last completed or current cycle status
- Add toggle to switch between last/current cycle view
- Add color coding (green/red/gray) for paid/unpaid/suspended
- Add filters for unpaid cycles in last/current cycle
- Efficiently load cycles to avoid N+1 queries
2025-12-18 15:08:31 +01:00
06de9d2c8b
feat: allow amount updates for membership fee cycles 2025-12-18 15:08:31 +01:00
09dfbe455b
feat: add membership fee helper modules
MembershipFeeHelpers: formatting functions for currency, intervals, cycles
MembershipFeeStatus: helper for loading and determining cycle status in member list
2025-12-18 15:08:30 +01:00
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
70e673034a
fix: remove unused variable warning in ValidateSameInterval 2025-12-18 15:00:43 +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
f0e1d3fade docs: document require_atomic? false in MembershipFeeType actions 2025-12-18 11:54:23 +01:00
78b5335456 refactor: migrate MembershipFeeSettingsLive to AshPhoenix.Form 2025-12-18 11:54:23 +01:00
511f52fba8 feat: improve error handling in settings validation for default_membership_fee_type_id 2025-12-18 11:54:23 +01:00
4813d6080b feat: prevent deletion of membership fee type when used as default in settings 2025-12-18 11:54:23 +01:00
283f824f4d fix: improve accessibility - WCAG 2 AA contrast and select label 2025-12-18 11:54:23 +01:00
630b51ac34 refactor: replace ContributionSettingsLive mockup with MembershipFeeSettingsLive in navigation 2025-12-18 11:54:23 +01:00
e135a6cdbf feat: implement full CRUD for membership fee types with settings UI
- Add interval immutability and deletion prevention validations
- Add settings validation for default_membership_fee_type_id
- Create MembershipFeeSettingsLive for admin UI with form handling
- Add comprehensive test coverage (unit, integration, settings)
2025-12-18 11:54:23 +01:00
ed083830b9 refactor: improve cycle generation code quality and documentation
All checks were successful
continuous-integration/drone/push Build is passing
- Remove Process.sleep calls from integration tests (tests run synchronously in SQL sandbox)
- Improve error handling: membership_fee_type_not_found now returns changeset error instead of just logging
- Clarify partial_failure documentation: successful_cycles are not persisted on rollback
- Update documentation: joined_at → join_date, left_at → exit_date
- Document PostgreSQL advisory locks per member (not whole table lock)
- Document gap handling: explicitly deleted cycles are not recreated
2025-12-16 16:40:11 +01:00
62a2bd41ea fix: handle Ash notifications in CycleGenerator transactions
- Use return_notifications?: true when creating cycles within transaction
- Collect notifications and send them after transaction commits
- Prevents 'Missed notifications' warnings in test output
- Notifications are now properly sent via Ash.Notifier.notify/1
2025-12-16 16:40:11 +01:00
de7a94ab07 fix: CycleGenerator generates from last cycle, not filling gaps
- Change algorithm to start from last existing cycle instead of start_date
- Deleted cycles (gaps) are no longer automatically filled
- Add test to verify gaps remain unfilled
- Update documentation to clarify gap handling behavior
2025-12-16 16:40:11 +01:00
13790dda43 feat: improve error handling in CycleGenerator
- Handle Task crashes in async_stream with {:exit, reason}
- Return {:error, {:partial_failure, successes, errors}} when some cycles fail
- Previously returned {:ok, successful} even on partial failures
- Improves debuggability and allows callers to handle partial failures
2025-12-16 16:40:11 +01:00
d01033c720 feat: include inactive members in batch cycle generation
- Remove exit_date filter from generate_cycles_for_all_members query
- Inactive members now get cycles generated up to their exit_date
- Add tests for inactive member processing and exit_date boundary
- Document exit_date == cycle_start behavior (cycle still generated)
2025-12-16 16:40:11 +01:00
78747d7da0 refactor: improve SetMembershipFeeStartDate change module
- Add warning logging for unexpected errors (not missing prerequisites)
- Use CalendarCycles.interval() type instead of generic atom()
- Update moduledoc to reflect actual usage (no where clause needed)
2025-12-16 16:40:11 +01:00
e899004b3c feat: add error logging in after_action cycle generation hooks
- Log warnings when cycle generation fails in Member create/update
- Extract generate_fn to reduce code duplication
- Improves debuggability of silent failures
2025-12-16 16:40:11 +01:00
434bcd269f refactor: use sql_sandbox config instead of env for sync/async
- Replace Application.get_env(:mv, :env) with :sql_sandbox config
- Remove redundant :env config from test.exs
- More explicit and less error-prone for test environment detection
2025-12-16 16:40:11 +01:00
25cc41b02e feat: implement automatic cycle generation for members
- Add CycleGenerator module with advisory lock mechanism
- Add SetMembershipFeeStartDate change for auto-calculation
- Extend Settings with include_joining_cycle and default_membership_fee_type_id
- Add scheduled job skeleton for future Oban integration
2025-12-16 16:40:11 +01:00
a7285915e6 docs: fix CalendarCycles documentation to match actual implementation
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-16 15:06:45 +01:00