[FEATURE]: Membership Fee 2 - Calendar Cycle Calculation Logic #276

Open
opened 2025-12-11 15:46:33 +01:00 by moritz · 0 comments
Owner

Goal: Implement the calendar-based cycle calculation functions.

Scope:

  • Create Mv.MembershipFees.CalendarCycles module
  • Implement functions:
    • calculate_cycle_start/3 - Given date and interval, find cycle start
    • calculate_cycle_end/2 - Given cycle_start and interval, calculate end
    • next_cycle_start/2 - Given cycle_start and interval, find next
    • is_current_cycle?/2 - Check if cycle contains today
    • is_last_completed_cycle?/2 - Check if cycle just ended
  • Support all interval types: monthly, quarterly, half_yearly, yearly
  • Handle edge cases: leap years, year boundaries, month boundaries

Files to Create:

  • lib/mv/membership_fees/calendar_cycles.ex

Tests to Write:

  • Unit Tests for Monthly Intervals:

    • Cycle start is always 1st of month
    • Cycle end is last day of month (handles 28/29/30/31 correctly)
    • Next cycle start calculation
    • Current cycle detection for various dates
    • Last completed cycle detection
  • Unit Tests for Quarterly Intervals:

    • Cycle starts: Jan 1, Apr 1, Jul 1, Oct 1
    • Cycle ends: Mar 31, Jun 30, Sep 30, Dec 31
    • Next cycle calculation across quarters
    • Current cycle detection
  • Unit Tests for Half-Yearly Intervals:

    • Cycle starts: Jan 1, Jul 1
    • Cycle ends: Jun 30, Dec 31
    • Next cycle calculation
  • Unit Tests for Yearly Intervals:

    • Cycle: Jan 1 to Dec 31
    • Next cycle calculation across years
  • Edge Case Tests:

    • Leap year handling (Feb 29)
    • Year boundary transitions (Dec 31 → Jan 1)
    • Today equals cycle start
    • Today equals cycle end
    • Date in middle of cycle

Acceptance Criteria:

  • All interval types calculate cycle boundaries correctly
  • Edge cases handled properly
  • Functions are pure (no side effects)
  • All tests pass
**Goal:** Implement the calendar-based cycle calculation functions. **Scope:** - Create `Mv.MembershipFees.CalendarCycles` module - Implement functions: - `calculate_cycle_start/3` - Given date and interval, find cycle start - `calculate_cycle_end/2` - Given cycle_start and interval, calculate end - `next_cycle_start/2` - Given cycle_start and interval, find next - `is_current_cycle?/2` - Check if cycle contains today - `is_last_completed_cycle?/2` - Check if cycle just ended - Support all interval types: monthly, quarterly, half_yearly, yearly - Handle edge cases: leap years, year boundaries, month boundaries **Files to Create:** - `lib/mv/membership_fees/calendar_cycles.ex` **Tests to Write:** - **Unit Tests for Monthly Intervals:** - Cycle start is always 1st of month - Cycle end is last day of month (handles 28/29/30/31 correctly) - Next cycle start calculation - Current cycle detection for various dates - Last completed cycle detection - **Unit Tests for Quarterly Intervals:** - Cycle starts: Jan 1, Apr 1, Jul 1, Oct 1 - Cycle ends: Mar 31, Jun 30, Sep 30, Dec 31 - Next cycle calculation across quarters - Current cycle detection - **Unit Tests for Half-Yearly Intervals:** - Cycle starts: Jan 1, Jul 1 - Cycle ends: Jun 30, Dec 31 - Next cycle calculation - **Unit Tests for Yearly Intervals:** - Cycle: Jan 1 to Dec 31 - Next cycle calculation across years - **Edge Case Tests:** - Leap year handling (Feb 29) - Year boundary transitions (Dec 31 → Jan 1) - Today equals cycle start - Today equals cycle end - Date in middle of cycle **Acceptance Criteria:** - All interval types calculate cycle boundaries correctly - Edge cases handled properly - Functions are pure (no side effects) - All tests pass
moritz added this to the Membership Fees milestone 2025-12-11 15:46:33 +01:00
moritz added the
medium priority
M
labels 2025-12-11 15:46:33 +01:00
moritz self-assigned this 2025-12-11 15:46:33 +01:00
moritz added this to the Sprint 10: 11.12-08.01 project 2025-12-11 15:46:34 +01:00
moritz changed title from [FEATURE]: Membership Fee - Calendar Cycle Calculation Logic to [FEATURE]: Membership Fee 2 - Calendar Cycle Calculation Logic 2025-12-11 15:50:22 +01:00
moritz added
S
and removed
M
labels 2025-12-11 19:48:39 +01:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: local-it/mitgliederverwaltung#276
No description provided.