Skip to content

Add payment-period budgeting, split monthly/period budget views, and period-start summary notifications#1002

Open
uniskela wants to merge 1 commit intoellite:mainfrom
uniskela:feat/payment-period-budgeting
Open

Add payment-period budgeting, split monthly/period budget views, and period-start summary notifications#1002
uniskela wants to merge 1 commit intoellite:mainfrom
uniskela:feat/payment-period-budgeting

Conversation

@uniskela
Copy link

Summary

This PR introduces a payment-period budgeting model (weekly/fortnightly/monthly + anchor date), separates monthly vs period budget tracking, and adds notification support for period summaries.

What Changed

1. Budget model and persistence

  • Added new budget-period helper logic:
    • includes/budget_period_calculations.php
  • Extended user budget handling:
    • endpoints/user/budget.php
    • Supports:
      • monthly_budget
      • period_budget
      • budget_period_type
      • budget_period_anchor_date
    • Keeps backward compatibility with legacy budget payload.

2. Migrations

  • migrations/000043.php
    • Adds user.budget_period_type
    • Adds user.budget_period_anchor_date
    • Backfills defaults
  • migrations/000044.php
    • Adds user.period_budget
    • Seeds from existing budget for existing users
  • migrations/000045.php
    • Adds notification_settings.period_summary_at_period_start

3. Settings UI / frontend

  • settings.php
    • Split into two sections:
      • Monthly Budget
      • Period Budget (amount + period type + anchor date)
    • Added notification toggle:
      • “Send summary at start of each payment period”
  • scripts/settings.js
    • Replaced single saveBudget() flow with:
      • saveMonthlyBudget()
      • savePeriodBudget()
  • scripts/notifications.js
    • Notification settings save now includes period_summary_at_period_start.

4. Stats and dashboard

  • includes/stats_calculations.php
    • Adds period-based amount-needed calculation
    • Separates monthly budget metrics from period budget metrics
  • stats.php
    • Added budget-type filter (monthly / period)
    • Added separate monthly vs period budget graph sections
    • Shows period label when relevant
  • scripts/stats.js
    • Added data-budgettype filter behavior
  • index.php
    • Shows separate monthly and period budget cards.

5. Notifications

  • endpoints/notifications/savenotificationsettings.php
    • Saves period_summary_at_period_start
  • endpoints/cronjobs/sendnotifications.php
    • Appends period summary line to renewal notifications
    • Supports optional summary-only send at period start
    • Reuses period calculation helper logic.

6. i18n

  • includes/i18n/en.php
    • Added new keys for period budget UI and notification summary labels
  • scripts/i18n/en.js
    • Added validation strings for budget form checks.

Notes

  • This PR intentionally excludes local/dev-only files (docker-compose.yaml, .gitignore, db/wallos.empty.db changes).

Validation

  • Ran php -l on all touched PHP files (all pass).
  • Manually validated:
    • Settings save flows for monthly and period budget
    • Stats filter and graph rendering
    • Notification settings save + cron message output with period summary

Test Plan

  1. Run migrations (000043, 000044, 000045).
  2. In Settings:
    • Save monthly budget.
    • Save period budget/type/anchor.
    • Enable period-start summary toggle.
  3. Verify Dashboard cards:
    • Monthly and period sections render correctly.
  4. Verify Stats:
    • Budget filter toggles between monthly/period.
    • Graphs render expected data.
  5. Trigger cron:
    • php endpoints/cronjobs/sendnotifications.php
    • Confirm renewal messages include period summary line.
    • Confirm summary-only send at period start when enabled.

Note: AI assistance was used during implementation; code was manually reviewed and tested before submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant