-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
🐛 Bug Report
Problem
Both Homebrew and Cargo installations of klirr fail with a period conflict error when using the default period ("Last") or explicitly specifying --period last.
Error Message
Error creating PDF: Start period ('2025-07-second-half') is after end period ('2025-07-first-half')
Code Logic Issue
The bug appears to be in the period calculation logic where:
- The system correctly identifies the target period as
2025-07-first-half(which should be the "last" period) - But internally during validation, it's comparing against
2025-07-second-half(current period) as the "start period" - This creates a logical conflict because
2025-07-second-half>2025-07-first-half
The issue suggests the validation logic is incorrectly treating the current period as the start period when it should be validating against the target period.
Reproduction Steps
❌ FAILS - Default period (both versions):
# Homebrew v0.2.0
/opt/homebrew/bin/klirr invoice services
# Result: period: 2025-07-first-half, ERROR: Start period ('2025-07-second-half') is after end period ('2025-07-first-half')
# Cargo v0.2.1
/Users/oscar/.cargo/bin/klirr invoice services
# Result: period: 2025-07-first-half, ERROR: Start period ('2025-07-second-half') is after end period ('2025-07-first-half')❌ FAILS - Explicit last period (both versions):
# Homebrew v0.2.0
/opt/homebrew/bin/klirr invoice --period last services
# Result: Same error
# Cargo v0.2.1
/Users/oscar/.cargo/bin/klirr invoice --period last services
# Result: Same error✅ WORKS - Current period (both versions):
# Homebrew v0.2.0
/opt/homebrew/bin/klirr invoice --period current services
# Result: period: 2025-07-second-half, SUCCESS
# Cargo v0.2.1
/Users/oscar/.cargo/bin/klirr invoice --period current services
# Result: period: 2025-07-second-half, SUCCESSEnvironment Details
- klirr versions:
- Homebrew: 0.2.0 (
/opt/homebrew/bin/klirr) - Cargo: 0.2.1 (
/Users/oscar/.cargo/bin/klirr)
- Homebrew: 0.2.0 (
- OS: macOS ARM64
- Test date: July 24, 2025 (second half of month)
- Bug confirmed: Both installations affected identically
Root Cause Analysis
The bug appears to be in the period validation logic where:
period: 2025-07-first-halfis correctly calculated as the target "last" period- During PDF generation, the validation incorrectly uses
2025-07-second-halfas a "start period" - The comparison
'2025-07-second-half' > '2025-07-first-half'triggers the error
The validation should either:
- Use the target period (
2025-07-first-half) as both start and end - Or properly calculate the date range for the target period without comparing against current period
Temporary Workaround
Use --period current instead of default/last period.
Metadata
Metadata
Assignees
Labels
No labels