{ "format": 1, "function": "resolve_range", "cases": [ { "name": "this_month", "input": { "preset": "this_month", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-10-01", "end_inclusive": "2026-10-17" } } }, { "name": "last_3_months: the current month and the two before", "input": { "preset": "last_3_months", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-08-01", "end_inclusive": "2026-10-17" } } }, { "name": "last_6_months", "input": { "preset": "last_6_months", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-05-01", "end_inclusive": "2026-10-17" } } }, { "name": "last_12_months: crosses into the previous year", "input": { "preset": "last_12_months", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2025-11-01", "end_inclusive": "2026-10-17" } } }, { "name": "this_year", "input": { "preset": "this_year", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-01-01", "end_inclusive": "2026-10-17" } } }, { "name": "all_time with an earliest expense", "input": { "preset": "all_time", "today": "2026-10-17", "earliest_expense": "2024-03-05", "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2024-03-05", "end_inclusive": "2026-10-17" } } }, { "name": "all_time without expenses: today to today", "input": { "preset": "all_time", "today": "2026-10-17", "earliest_expense": null, "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-10-17", "end_inclusive": "2026-10-17" } } }, { "name": "custom in order, future dates allowed", "input": { "preset": "custom", "today": "2026-10-17", "earliest_expense": null, "custom_start": "2026-11-01", "custom_end": "2026-12-31" }, "expected": { "ok": { "start": "2026-11-01", "end_inclusive": "2026-12-31" } } }, { "name": "custom swapped when start is after end", "input": { "preset": "custom", "today": "2026-10-17", "earliest_expense": null, "custom_start": "2026-12-31", "custom_end": "2026-11-01" }, "expected": { "ok": { "start": "2026-11-01", "end_inclusive": "2026-12-31" } } }, { "name": "custom single day", "input": { "preset": "custom", "today": "2026-10-17", "earliest_expense": null, "custom_start": "2026-02-28", "custom_end": "2026-02-28" }, "expected": { "ok": { "start": "2026-02-28", "end_inclusive": "2026-02-28" } } }, { "name": "last_3_months in January crosses the year", "input": { "preset": "last_3_months", "today": "2027-01-01", "earliest_expense": null, "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-11-01", "end_inclusive": "2027-01-01" } } }, { "name": "last_12_months on 31 March: first of April the year before", "input": { "preset": "last_12_months", "today": "2027-03-31", "earliest_expense": null, "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-04-01", "end_inclusive": "2027-03-31" } } }, { "name": "this_month on the first day of the month", "input": { "preset": "this_month", "today": "2026-11-01", "earliest_expense": null, "custom_start": null, "custom_end": null }, "expected": { "ok": { "start": "2026-11-01", "end_inclusive": "2026-11-01" } } } ] }